diff options
Diffstat (limited to 'lua/autocommands')
-rw-r--r-- | lua/autocommands/NERDTree.lua | 1 | ||||
-rw-r--r-- | lua/autocommands/buffer.lua | 4 | ||||
-rw-r--r-- | lua/autocommands/coc.lua | 9 | ||||
-rw-r--r-- | lua/autocommands/exit.lua | 38 | ||||
-rw-r--r-- | lua/autocommands/init.lua | 5 |
5 files changed, 57 insertions, 0 deletions
diff --git a/lua/autocommands/NERDTree.lua b/lua/autocommands/NERDTree.lua new file mode 100644 index 0000000..38213e2 --- /dev/null +++ b/lua/autocommands/NERDTree.lua @@ -0,0 +1 @@ +autocmd("VimEnter", "*", "NERDTree") diff --git a/lua/autocommands/buffer.lua b/lua/autocommands/buffer.lua new file mode 100644 index 0000000..da330c8 --- /dev/null +++ b/lua/autocommands/buffer.lua @@ -0,0 +1,4 @@ +require("utility.autocmd") + +-- autocmd("BufEnter", "*", "lua remove_hidden_windowless_buffers()") + diff --git a/lua/autocommands/coc.lua b/lua/autocommands/coc.lua new file mode 100644 index 0000000..965cca2 --- /dev/null +++ b/lua/autocommands/coc.lua @@ -0,0 +1,9 @@ +require("utility.autocmd") + +-- Highlight the symbol and its references when holding the cursor. +autocmd("CursorHold", "*", "silent call CocActionAsync('highlight')") + +augroup("coc-misc", { + -- {"FileType", "typescript,json", "setl formatexpr=CocAction('formatSelected')"}, + {"User", "CocJumpPlaceholder", "call CocActionAsync('showSignatureHelp')"}}) + diff --git a/lua/autocommands/exit.lua b/lua/autocommands/exit.lua new file mode 100644 index 0000000..8ffac46 --- /dev/null +++ b/lua/autocommands/exit.lua @@ -0,0 +1,38 @@ +require("utility.autocmd") + +-- Exit Vim if NERDTree is the only window remaining in the only tab. +--[[ +autocmd( + "BufEnter", + "*", + "if tabpagenr('$') == 1 && winnr('$') == 1 && " .. + "exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif" +) +]] + +-- Exit Vim if a terminal is the only window remaining in the only tab. +--[[ +autocmd( + "BufEnter", + "*", + "if tabpagenr('$') == 1 && winnr('$') == 1 && g:is_term_open == 1 | quit | endif" +) + +-- Exit Vim if the only windows remaining is NERDTree and terminal. +autocmd( + "BufEnter", + "*", + "if tabpagenr('$') == 1 && winnr('$') == 2 && g:NERDTree.IsOpen() && " .. + "g:is_term_open == 1 | qall | endif" +) +]] + +-- Close a single NERDTree tab. +--[[ +autocmd( + "BufEnter", + "*", + "if len(tabpagebuflist()) == 1 && bufname(tabpagebuflist()[0]) =~ \"^NERD_tree\" " .. + "| tabclose | endif" +) +]] diff --git a/lua/autocommands/init.lua b/lua/autocommands/init.lua new file mode 100644 index 0000000..23679e9 --- /dev/null +++ b/lua/autocommands/init.lua @@ -0,0 +1,5 @@ +require("autocommands.coc") +require("autocommands.exit") +require("autocommands.buffer") +require("autocommands.NERDTree") + |