From 690372bd8889200bb5bfba6e0cd9d66d76aeddf1 Mon Sep 17 00:00:00 2001 From: PeteChu Date: Fri, 21 Apr 2023 17:03:44 +0700 Subject: [PATCH] switch from nvimtree to neotree --- after/plugin/file-explorer.lua | 0 after/plugin/grep.vim | 4 +-- after/plugin/harpoon.lua | 7 +++++ after/plugin/keymaps.lua | 7 +++-- after/plugin/nvim-tree.lua | 42 ---------------------------- init.lua | 6 ++++ lua/custom/plugins/bufferline.lua | 3 +- lua/custom/plugins/file-explorer.lua | 31 ++++++++++++++++++++ lua/custom/plugins/init.lua | 9 ++++-- lua/custom/plugins/lsp_signature.lua | 10 +++++-- lua/custom/plugins/nvim-tree.lua | 14 ---------- lua/custom/plugins/snippets.lua | 2 ++ lua/custom/plugins/trouble.lua | 3 +- 13 files changed, 69 insertions(+), 69 deletions(-) create mode 100644 after/plugin/file-explorer.lua delete mode 100644 after/plugin/nvim-tree.lua create mode 100644 lua/custom/plugins/file-explorer.lua delete mode 100644 lua/custom/plugins/nvim-tree.lua create mode 100644 lua/custom/plugins/snippets.lua diff --git a/after/plugin/file-explorer.lua b/after/plugin/file-explorer.lua new file mode 100644 index 00000000..e69de29b diff --git a/after/plugin/grep.vim b/after/plugin/grep.vim index a6ea06bb..0fa0218d 100644 --- a/after/plugin/grep.vim +++ b/after/plugin/grep.vim @@ -12,6 +12,6 @@ cnoreabbrev lgrep (getcmdtype() ==# ':' && getcmdline() ==# 'lgrep') ? 'L augroup quickfix autocmd! - autocmd QuickFixCmdPost cgetexpr TroubleToggle quickfix - autocmd QuickFixCmdPost lgetexpr TroubleToggle loclist + autocmd QuickFixCmdPost cgetexpr cwindow + autocmd QuickFixCmdPost lgetexpr lwindow augroup END diff --git a/after/plugin/harpoon.lua b/after/plugin/harpoon.lua index 50b01072..4c95e602 100644 --- a/after/plugin/harpoon.lua +++ b/after/plugin/harpoon.lua @@ -6,3 +6,10 @@ vim.keymap.set("n", "", ui.toggle_quick_menu) vim.keymap.set("n", "hn", function() ui.nav_next() end, { desc = "[H]arpoon [N]ext" }) vim.keymap.set("n", "hp", function() ui.nav_prev() end, { desc = "[H]arpoon [P]revious" }) + +vim.keymap.set("n", "h1", function() ui.nav_file(1) end, { desc = "[H]arpoon [1]" }) +vim.keymap.set("n", "h2", function() ui.nav_file(2) end, { desc = "[H]arpoon [2]" }) +vim.keymap.set("n", "h3", function() ui.nav_file(3) end, { desc = "[H]arpoon [3]" }) +vim.keymap.set("n", "h4", function() ui.nav_file(4) end, { desc = "[H]arpoon [4]" }) +vim.keymap.set("n", "h5", function() ui.nav_file(5) end, { desc = "[H]arpoon [5]" }) +vim.keymap.set("n", "h6", function() ui.nav_file(6) end, { desc = "[H]arpoon [6]" }) diff --git a/after/plugin/keymaps.lua b/after/plugin/keymaps.lua index bc7a0751..ba8c1153 100644 --- a/after/plugin/keymaps.lua +++ b/after/plugin/keymaps.lua @@ -23,8 +23,9 @@ keymap("n", "", "j", opts) keymap("n", "", "k", opts) keymap("n", "", "l", opts) --- Nvimtree -keymap('n', 'n', ":NvimTreeToggle", { silent = true, noremap = true, desc = "Toggle [N]vimtree" }) +-- File Explorer +-- keymap('n', 'n', ":NvimTreeToggle", { silent = true, noremap = true, desc = "Toggle [N]vimtree" }) +keymap('n', 'n', ":NeoTreeShowToggle", { silent = true, noremap = true, desc = "Toggle [N]eoTree" }) -- UndoTree keymap('n', 'u', ":UndotreeToggle", { desc = "Toggle [U]ndo tree" }) @@ -60,7 +61,7 @@ keymap("n", "dl", [[:g/\<\>/d]], { desc = "[D]elete [L]ine with selected word in the file" }) -- Make file executable -keymap("n", "x", "!chmod +x %", { silent = true, desc = "Make [X]ecutable file" }) +keymap("n", "X", "!chmod +x %", { silent = true, desc = "Make [X]ecutable file" }) -- Do nothing keymap("n", "Q", "") diff --git a/after/plugin/nvim-tree.lua b/after/plugin/nvim-tree.lua deleted file mode 100644 index d9547473..00000000 --- a/after/plugin/nvim-tree.lua +++ /dev/null @@ -1,42 +0,0 @@ -local function open_nvim_tree(data) - -- buffer is a real file on the disk - local real_file = vim.fn.filereadable(data.file) == 1 - - -- buffer is a [No Name] - local no_name = data.file == "" and vim.bo[data.buf].buftype == "" - - if not real_file and not no_name then - return - end - - -- open the tree, find the file but don't focus it - require("nvim-tree.api").tree.toggle({ focus = false, find_file = true, }) -end - --- Auto open --- vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree }) - --- Auto close -vim.api.nvim_create_autocmd({ "QuitPre" }, { - callback = function() vim.cmd("NvimTreeClose") end, -}) - --- Go to last used hidden buffer when deleting a buffer -vim.api.nvim_create_autocmd("BufEnter", { - nested = true, - callback = function() - -- Only 1 window with nvim-tree left: we probably closed a file buffer - if #vim.api.nvim_list_wins() == 1 and require("nvim-tree.utils").is_nvim_tree_buf() then - local api = require('nvim-tree.api') - -- Required to let the close event complete. An error is thrown without this. - vim.defer_fn(function() - -- close nvim-tree: will go to the last hidden buffer used before closing - api.tree.toggle({ find_file = true, focus = true }) - -- re-open nivm-tree - api.tree.toggle({ find_file = true, focus = true }) - -- nvim-tree is still the active window. Go to the previous window. - vim.cmd("wincmd p") - end, 0) - end - end -}) diff --git a/init.lua b/init.lua index dde8d417..f8b8e6c8 100644 --- a/init.lua +++ b/init.lua @@ -501,6 +501,7 @@ mason_lspconfig.setup_handlers { -- nvim-cmp setup local cmp = require 'cmp' +local cmp_autopairs = require 'nvim-autopairs.completion.cmp' local luasnip = require 'luasnip' local lspkind = require 'lspkind' @@ -546,6 +547,7 @@ cmp.setup { { name = 'luasnip' }, { name = 'buffer' }, { name = 'path' }, + { name = 'rg' } }), formatting = { format = lspkind.cmp_format({ @@ -554,6 +556,10 @@ cmp.setup { }) } } +cmp.event:on( + 'confirm_done', + cmp_autopairs.on_confirm_done() +) -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et diff --git a/lua/custom/plugins/bufferline.lua b/lua/custom/plugins/bufferline.lua index c9f0a00f..d5f07dd4 100644 --- a/lua/custom/plugins/bufferline.lua +++ b/lua/custom/plugins/bufferline.lua @@ -8,7 +8,8 @@ return { indicator = { style = "icon", icon = "▎" }, diagnostics = 'nvim_lsp', -- | "nvim_lsp" | "coc", diagnostics_update_in_insert = false, - offsets = { { filetype = "NvimTree", text = "File Explorer", padding = 1 } }, + -- offsets = { { filetype = "NvimTree", text = "File Explorer", padding = 1 } }, + offsets = { { filetype = "neo-tree", text = "File Explorer", padding = 1 } }, separator_style = "thin", -- | "thick" | "thin" | { 'any', 'any' }, always_show_bufferline = true, sort_by = "insert_at_end" diff --git a/lua/custom/plugins/file-explorer.lua b/lua/custom/plugins/file-explorer.lua new file mode 100644 index 00000000..11bc643b --- /dev/null +++ b/lua/custom/plugins/file-explorer.lua @@ -0,0 +1,31 @@ +return { + "nvim-neo-tree/neo-tree.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended + "MunifTanjim/nui.nvim", + }, + config = function() + vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]]) + local ntree = require 'neo-tree' + ntree.setup({ + close_if_last_window = true, + window = { + width = 30, + mappings = { + ["o"] = "open", + ["F"] = "clear_filter", + ['e'] = function() vim.api.nvim_command('Neotree focus filesystem left') end, + ['b'] = function() vim.api.nvim_command('Neotree focus buffers left') end, + ['g'] = function() vim.api.nvim_command('Neotree focus git_status left') end, + } + }, + filesystem = { + follow_current_file = true + }, + source_selector = { + winbar = true + } + }) + end +} diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index eb1c829d..44252e3b 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -2,12 +2,17 @@ -- I promise not to create any merge conflicts in this directory :) -- -- See the kickstart.nvim README for more information + return { 'fatih/vim-go', 'famiu/bufdelete.nvim', 'ThePrimeagen/harpoon', 'ThePrimeagen/vim-be-good', 'stevearc/dressing.nvim', - "onsails/lspkind.nvim" - -- "rafamadriz/friendly-snippets" + "onsails/lspkind.nvim", + 'lukas-reineke/cmp-rg', + 'onsails/diaglist.nvim', + config = function() + require('diaglist').init() + end } diff --git a/lua/custom/plugins/lsp_signature.lua b/lua/custom/plugins/lsp_signature.lua index 479d6677..17420ce8 100644 --- a/lua/custom/plugins/lsp_signature.lua +++ b/lua/custom/plugins/lsp_signature.lua @@ -1,6 +1,10 @@ return { 'ray-x/lsp_signature.nvim', - config = function() - require('lsp_signature').setup {} + config = function() + local cfg = { + floating_window_above_cur_line = true, + doc_lines = 0, + } + require('lsp_signature').setup(cfg) end -} \ No newline at end of file +} diff --git a/lua/custom/plugins/nvim-tree.lua b/lua/custom/plugins/nvim-tree.lua deleted file mode 100644 index 6b044a45..00000000 --- a/lua/custom/plugins/nvim-tree.lua +++ /dev/null @@ -1,14 +0,0 @@ -return { - { - "nvim-tree/nvim-tree.lua", - version = "*", - dependencies = { - "nvim-tree/nvim-web-devicons", - }, - config = function() - require("nvim-tree").setup { - filters = { custom = { "^.git$" } }, - } - end, - } -} diff --git a/lua/custom/plugins/snippets.lua b/lua/custom/plugins/snippets.lua new file mode 100644 index 00000000..97aeaddb --- /dev/null +++ b/lua/custom/plugins/snippets.lua @@ -0,0 +1,2 @@ +return { +} diff --git a/lua/custom/plugins/trouble.lua b/lua/custom/plugins/trouble.lua index f101c64a..3f3447d6 100755 --- a/lua/custom/plugins/trouble.lua +++ b/lua/custom/plugins/trouble.lua @@ -4,7 +4,6 @@ return { "nvim-tree/nvim-web-devicons" }, config = function() - require("trouble").setup { - } + require("trouble").setup {} end }