summaryrefslogtreecommitdiffstats
path: root/.config/nvim
diff options
context:
space:
mode:
authorYigit Sever2021-10-08 13:40:08 +0300
committerYigit Sever2021-10-08 13:40:41 +0300
commit484188c99b21e668f40b84b21d1b21f5b9ce8d9e (patch)
tree97592a6667dafe35eb51171c4485208da1e5abba /.config/nvim
parent98795863769fc46b78439b39a97c5d2c057fbb80 (diff)
downloaddotfiles-484188c99b21e668f40b84b21d1b21f5b9ce8d9e.tar.gz
dotfiles-484188c99b21e668f40b84b21d1b21f5b9ce8d9e.tar.bz2
dotfiles-484188c99b21e668f40b84b21d1b21f5b9ce8d9e.zip
nvim: autocommands
Diffstat (limited to '.config/nvim')
-rw-r--r--.config/nvim/init.lua1
-rw-r--r--.config/nvim/lua/au.lua50
-rw-r--r--.config/nvim/lua/autocmds.lua59
-rw-r--r--.config/nvim/lua/plugin_settings.lua2
-rw-r--r--.config/nvim/lua/plugins.lua12
5 files changed, 116 insertions, 8 deletions
diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua
index ae54ee1..9dcc9b5 100644
--- a/.config/nvim/init.lua
+++ b/.config/nvim/init.lua
@@ -13,5 +13,6 @@
13 13
14require('plugins') 14require('plugins')
15require('settings') 15require('settings')
16require('autocmds')
16require('mappings') 17require('mappings')
17require('plugin_settings') 18require('plugin_settings')
diff --git a/.config/nvim/lua/au.lua b/.config/nvim/lua/au.lua
new file mode 100644
index 0000000..305169c
--- /dev/null
+++ b/.config/nvim/lua/au.lua
@@ -0,0 +1,50 @@
1--
2-- https://gist.github.com/numToStr/1ab83dd2e919de9235f9f774ef8076da
3--
4local cmd = vim.api.nvim_command
5
6local function autocmd(this, event, spec)
7 local is_table = type(spec) == 'table'
8 local pattern = is_table and spec[1] or '*'
9 local action = is_table and spec[2] or spec
10 if type(action) == 'function' then
11 action = this.set(action)
12 end
13 local e = type(event) == 'table' and table.concat(event, ',') or event
14 cmd('autocmd ' .. e .. ' ' .. pattern .. ' ' .. action)
15end
16
17local S = {
18 __au = {},
19}
20
21local X = setmetatable({}, {
22 __index = S,
23 __newindex = autocmd,
24 __call = autocmd,
25})
26
27function S.exec(id)
28 S.__au[id]()
29end
30
31function S.set(fn)
32 local id = string.format('%p', fn)
33 S.__au[id] = fn
34 return string.format('lua require("au").exec("%s")', id)
35end
36
37function S.group(grp, cmds)
38 cmd('augroup ' .. grp)
39 cmd('autocmd!')
40 if type(cmds) == 'function' then
41 cmds(X)
42 else
43 for _, au in ipairs(cmds) do
44 autocmd(S, au[1], { au[2], au[3] })
45 end
46 end
47 cmd('augroup END')
48end
49
50return X
diff --git a/.config/nvim/lua/autocmds.lua b/.config/nvim/lua/autocmds.lua
new file mode 100644
index 0000000..295dcc2
--- /dev/null
+++ b/.config/nvim/lua/autocmds.lua
@@ -0,0 +1,59 @@
1-- ┌─────────────────────────┐
2-- │ ▐ ▌ │
3-- │▝▀▖▌ ▌▜▀ ▞▀▖▞▀▖▛▚▀▖▞▀▌▞▀▘│
4-- │▞▀▌▌ ▌▐ ▖▌ ▌▌ ▖▌▐ ▌▌ ▌▝▀▖│
5-- │▝▀▘▝▀▘ ▀ ▝▀ ▝▀ ▘▝ ▘▝▀▘▀▀ │
6-- └─────────────────────────┘
7
8local au = require('au')
9
10au.TextYankPost = function()
11 vim.highlight.on_yank({ higroup = 'Visual', timeout = 120 })
12end
13
14au.BufEnter = {
15 'PKGBUILD',
16 function()
17 vim.bo.filetype = "PKGBUILD"
18 end,
19}
20
21-- autocmd FileType vimwiki,latex,tex setlocal formatprg=/home/yigit/.local/bin/sentences
22au.FileType = {
23 'vimwiki,latex,tex',
24 function()
25 vim.bo.formatprg = "/home/yigit/.local/bin/sentences"
26 end,
27}
28
29-- autocmd VimLeave *.tex !texclear %
30au.VimLeave = {
31 '*.tex',
32 function()
33 vim.cmd("!texclear %")
34 end,
35}
36
37-- autocmd FileType rust let b:dispatch = 'cargo run'
38au.FileType = {
39 'rust',
40 function()
41 vim.b.dispatch = 'cargo run'
42 end,
43}
44
45-- autocmd VimResized * :wincmd =
46au.VimResized = {
47 '*',
48 function()
49 vim.cmd(":wincmd =")
50 end,
51}
52
53-- autocmd FileType markdown,tex setlocal spell
54au.FileType = {
55 'markdown,text',
56 function()
57 vim.bo.spell = true
58 end,
59}
diff --git a/.config/nvim/lua/plugin_settings.lua b/.config/nvim/lua/plugin_settings.lua
index 6de7ebd..b10a002 100644
--- a/.config/nvim/lua/plugin_settings.lua
+++ b/.config/nvim/lua/plugin_settings.lua
@@ -37,7 +37,7 @@ g.vimwiki_hl_headers = 1
37-- lualine {{{ -- 37-- lualine {{{ --
38require'lualine'.setup { 38require'lualine'.setup {
39 options = { 39 options = {
40 lower = true, 40 lower = false,
41 icons_enabled = true, 41 icons_enabled = true,
42 theme = 'rose-pine', 42 theme = 'rose-pine',
43 section_separators = {'', ''}, 43 section_separators = {'', ''},
diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua
index 58cccbc..4f5420f 100644
--- a/.config/nvim/lua/plugins.lua
+++ b/.config/nvim/lua/plugins.lua
@@ -6,7 +6,7 @@
6-- └───────────────────┘ 6-- └───────────────────┘
7 7
8return require('packer').startup(function() 8return require('packer').startup(function()
9 -- Packer can manage itself 9 -- packer can manage itself
10 use 'wbthomason/packer.nvim' 10 use 'wbthomason/packer.nvim'
11 11
12 -- latex suite 12 -- latex suite
@@ -22,8 +22,6 @@ return require('packer').startup(function()
22 use 'jpalardy/vim-slime' 22 use 'jpalardy/vim-slime'
23 -- snippets to expand 23 -- snippets to expand
24 use {'SirVer/ultisnips', 'honza/vim-snippets'} 24 use {'SirVer/ultisnips', 'honza/vim-snippets'}
25 -- Highlight the yanked region
26 use 'machakann/vim-highlightedyank'
27 25
28 -- auto pair plugin, people hate these 26 -- auto pair plugin, people hate these
29 use 'tmsvg/pear-tree' 27 use 'tmsvg/pear-tree'
@@ -50,13 +48,13 @@ return require('packer').startup(function()
50 48
51 -- displays tags ordered by scope 49 -- displays tags ordered by scope
52 use 'majutsushi/tagbar' 50 use 'majutsushi/tagbar'
53 -- Undo tree 51 -- undo tree
54 use { 52 use {
55 'mbbill/undotree', 53 'mbbill/undotree',
56 cmd = 'UndotreeToggle', 54 cmd = 'UndotreeToggle',
57 config = [[vim.g.undotree_SetFocusWhenToggle = 1]], 55 config = [[vim.g.undotree_SetFocusWhenToggle = 1]],
58 } 56 }
59 -- Highlight colors 57 -- highlight colors
60 use { 58 use {
61 'norcalli/nvim-colorizer.lua', 59 'norcalli/nvim-colorizer.lua',
62 ft = { 'css', 'javascript', 'vim', 'html' }, 60 ft = { 'css', 'javascript', 'vim', 'html' },
@@ -70,7 +68,7 @@ return require('packer').startup(function()
70 'svermeulen/vim-yoink' 68 'svermeulen/vim-yoink'
71 } 69 }
72 70
73 -- Personal wiki 71 -- personal wiki
74 use 'vimwiki/vimwiki' 72 use 'vimwiki/vimwiki'
75 -- centers the writing 73 -- centers the writing
76 use 'junegunn/goyo.vim' 74 use 'junegunn/goyo.vim'
@@ -78,7 +76,7 @@ return require('packer').startup(function()
78 use 'junegunn/limelight.vim' 76 use 'junegunn/limelight.vim'
79 -- change ASCII text to Turkish text 77 -- change ASCII text to Turkish text
80 use 'yigitsever/turkish-deasciifier.vim' 78 use 'yigitsever/turkish-deasciifier.vim'
81 79
82 -- text alignment \w :Tab 80 -- text alignment \w :Tab
83 use 'godlygeek/tabular' 81 use 'godlygeek/tabular'
84 -- move selections up and down with alt+[j,k] 82 -- move selections up and down with alt+[j,k]