diff options
Diffstat (limited to 'nvim/lua/config/autocmds.lua')
| -rw-r--r-- | nvim/lua/config/autocmds.lua | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/nvim/lua/config/autocmds.lua b/nvim/lua/config/autocmds.lua index e11b231..647875d 100644 --- a/nvim/lua/config/autocmds.lua +++ b/nvim/lua/config/autocmds.lua | |||
| @@ -1,10 +1,10 @@ | |||
| 1 | -- https://github.com/nvim-treesitter/nvim-treesitter/blob/main/doc/nvim-treesitter.txt | 1 | -- https://github.com/nvim-treesitter/nvim-treesitter/blob/main/doc/nvim-treesitter.txt |
| 2 | vim.api.nvim_create_autocmd('FileType', { | 2 | vim.api.nvim_create_autocmd("FileType", { |
| 3 | pattern = { "c", "cpp", "lua", "typescript" }, | 3 | pattern = { "c", "cpp", "lua", "typescript" }, |
| 4 | callback = function() | 4 | callback = function() |
| 5 | vim.treesitter.start() | 5 | vim.treesitter.start() |
| 6 | vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()' | 6 | vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()" |
| 7 | vim.wo.foldmethod = 'expr' | 7 | vim.wo.foldmethod = "expr" |
| 8 | vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" | 8 | vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" |
| 9 | end, | 9 | end, |
| 10 | }) | 10 | }) |
| @@ -18,13 +18,11 @@ vim.api.nvim_create_autocmd("VimEnter", { | |||
| 18 | -- buffer is a [No Name] | 18 | -- buffer is a [No Name] |
| 19 | local no_name = data.file == "" and vim.bo[data.buf].buftype == "" | 19 | local no_name = data.file == "" and vim.bo[data.buf].buftype == "" |
| 20 | 20 | ||
| 21 | if not real_file and not no_name then | 21 | if not real_file and not no_name then return end |
| 22 | return | ||
| 23 | end | ||
| 24 | 22 | ||
| 25 | -- open the tree, find the file but don't focus it | 23 | -- open the tree, find the file but don't focus it |
| 26 | require("nvim-tree.api").tree.toggle({ focus = false, find_file = true, }) | 24 | require("nvim-tree.api").tree.toggle({ focus = false, find_file = true }) |
| 27 | end | 25 | end, |
| 28 | }) | 26 | }) |
| 29 | 27 | ||
| 30 | -- https://github.com/nvim-tree/nvim-tree.lua/wiki/Auto-Close | 28 | -- https://github.com/nvim-tree/nvim-tree.lua/wiki/Auto-Close |
| @@ -35,16 +33,16 @@ vim.api.nvim_create_autocmd("QuitPre", { | |||
| 35 | 33 | ||
| 36 | for _, w in ipairs(wins) do | 34 | for _, w in ipairs(wins) do |
| 37 | local bufname = vim.api.nvim_buf_get_name(vim.api.nvim_win_get_buf(w)) | 35 | local bufname = vim.api.nvim_buf_get_name(vim.api.nvim_win_get_buf(w)) |
| 38 | if bufname:match("NvimTree_") ~= nil then | 36 | if bufname:match("NvimTree_") ~= nil then table.insert(invalid_win, w) end |
| 39 | table.insert(invalid_win, w) | ||
| 40 | end | ||
| 41 | end | 37 | end |
| 42 | 38 | ||
| 43 | if #invalid_win == #wins - 1 then | 39 | if #invalid_win == #wins - 1 then |
| 44 | -- Should quit, so we close all invalid windows. | 40 | -- Should quit, so we close all invalid windows. |
| 45 | for _, w in ipairs(invalid_win) do vim.api.nvim_win_close(w, true) end | 41 | for _, w in ipairs(invalid_win) do |
| 42 | vim.api.nvim_win_close(w, true) | ||
| 43 | end | ||
| 46 | end | 44 | end |
| 47 | end | 45 | end, |
| 48 | }) | 46 | }) |
| 49 | 47 | ||
| 50 | vim.api.nvim_create_autocmd("LspAttach", { | 48 | vim.api.nvim_create_autocmd("LspAttach", { |
