From e77710152394980449d530b59fda2ad1b1a20158 Mon Sep 17 00:00:00 2001 From: leafee98 Date: Thu, 22 Aug 2024 22:54:58 +0800 Subject: [PATCH] Refactor plugins - Add marks.nvim - Use mason to setup LSP - config lua_ls for neovim config - Disable treesitter - Remove scroll plugin - Remove mini-animate --- init.lua | 2 +- lua/plugins/10-editor.lua | 25 +++++++++-------- lua/plugins/20-treesitter.lua | 1 + lua/plugins/50-lsp.lua | 52 +++++++++++++++++++++++++++++------ lua/plugins/guess-indent.lua | 3 -- lua/plugins/mini-animate.lua | 8 ------ lua/plugins/smart-splits.lua | 41 +++++++++++++++++++++------ 7 files changed, 91 insertions(+), 41 deletions(-) delete mode 100644 lua/plugins/guess-indent.lua delete mode 100644 lua/plugins/mini-animate.lua diff --git a/init.lua b/init.lua index 2638ef5..fb69b1f 100644 --- a/init.lua +++ b/init.lua @@ -29,7 +29,7 @@ vim.g.maplocalleader = " " vim.keymap.set("n", "\\\\", "split", { silent = true }) vim.keymap.set("n", "||", "vsplit", { silent = true }) -vim.keymap.set("n", "\\q", "wincmd q", { silent = true }) +vim.keymap.set("n", "q", "wincmd q", { silent = true }) vim.keymap.set("n", "", "wincmd h", { silent = true }) vim.keymap.set("n", "", "wincmd j", { silent = true }) vim.keymap.set("n", "", "wincmd k", { silent = true }) diff --git a/lua/plugins/10-editor.lua b/lua/plugins/10-editor.lua index 2638263..53c6c13 100644 --- a/lua/plugins/10-editor.lua +++ b/lua/plugins/10-editor.lua @@ -18,22 +18,23 @@ return { }, }, }, + { + "NMAC427/guess-indent.nvim", + }, + { + "chentoast/marks.nvim", + opts = { + builtin_marks = { ".", "<", ">", "^" }, + mappings = { + next = "]m", + prev = "[m", + }, + }, + }, { "famiu/bufdelete.nvim", keys = { { "c", "Bdelete", mode = "n" }, }, }, - { - "dstein64/nvim-scrollview", - enabled = custom.full_feature, - event = "VeryLazy", - opts = { - excluded_filetypes = { "NvimTree" }, - current_only = false, - base = "right", - signs_on_startup = { "all" }, - diagnostics_severities = { vim.diagnostic.severity.ERROR } - }, - } } diff --git a/lua/plugins/20-treesitter.lua b/lua/plugins/20-treesitter.lua index 175a258..c1d7627 100644 --- a/lua/plugins/20-treesitter.lua +++ b/lua/plugins/20-treesitter.lua @@ -1,5 +1,6 @@ return { "nvim-treesitter/nvim-treesitter", + enabled = false, name = "nvim-treesitter", event = "VeryLazy", build = ":TSUpdate", diff --git a/lua/plugins/50-lsp.lua b/lua/plugins/50-lsp.lua index ec7f714..67518d2 100644 --- a/lua/plugins/50-lsp.lua +++ b/lua/plugins/50-lsp.lua @@ -36,6 +36,29 @@ function setup_keymap_lsp() }) end +local lua_ls_opts = { + settings = { + Lua = { + runtime = { + -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) + version = "LuaJIT", + }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = { "vim" }, + }, + workspace = { + -- Make the server aware of Neovim runtime files + library = vim.api.nvim_get_runtime_file("", true), + }, + -- Do not send telemetry data containing a randomized but unique identifier + telemetry = { + enable = false, + }, + }, + }, +} + return { { "neovim/nvim-lspconfig", @@ -47,21 +70,32 @@ return { "hrsh7th/cmp-path", "hrsh7th/cmp-cmdline", "L3MON4D3/LuaSnip", + + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + "mfussenegger/nvim-lint", + "mhartington/formatter.nvim", }, event = { "BufReadPre", "BufNewFile", "VeryLazy" }, cmd = { "LspInfo", "LspInstall", "LspUninstall" }, config = function (_, opts) - local capabilities = require("cmp_nvim_lsp").default_capabilities() - - local servers = { "clangd", "rust_analyzer", "pyright", "gopls", "quick_lint_js" } - for _, lsp in ipairs(servers) do - require("lspconfig")[lsp].setup{ - capabilities = capabilities, - } - end - + local mason = require("mason") + local mason_lsp = require("mason-lspconfig") local luasnip = require("luasnip") local cmp = require("cmp") + + mason.setup() + mason_lsp.setup() + mason_lsp.setup_handlers { + function (server_name) -- default handler (optional) + require("lspconfig")[server_name].setup {} + end, + + ["lua_ls"] = function () + require("lspconfig")["lua_ls"].setup(lua_ls_opts) + end + } + cmp.setup({ snippet = { expand = function(args) diff --git a/lua/plugins/guess-indent.lua b/lua/plugins/guess-indent.lua deleted file mode 100644 index 5660def..0000000 --- a/lua/plugins/guess-indent.lua +++ /dev/null @@ -1,3 +0,0 @@ -return { - "NMAC427/guess-indent.nvim", -} diff --git a/lua/plugins/mini-animate.lua b/lua/plugins/mini-animate.lua deleted file mode 100644 index 1b19a92..0000000 --- a/lua/plugins/mini-animate.lua +++ /dev/null @@ -1,8 +0,0 @@ -return { - "echasnovski/mini.animate", - main = "mini.animate", - opt = {}, - config = function() - require("mini.animate").setup() - end, -} diff --git a/lua/plugins/smart-splits.lua b/lua/plugins/smart-splits.lua index 71089e6..8fbadcf 100644 --- a/lua/plugins/smart-splits.lua +++ b/lua/plugins/smart-splits.lua @@ -3,13 +3,38 @@ return { event = "VeryLazy", opts = { ignored_filetypes = { "nofile", "quickfix", "qf", "prompt" }, ignored_buftypes = { "nofile" } }, keys = { - { "", function() require("smart-splits").move_cursor_left() end, desc = "Move to left split" }, - { "", function() require("smart-splits").move_cursor_down() end, desc = "Move to below split" }, - { "", function() require("smart-splits").move_cursor_up() end, desc = "Move to above split" }, - { "", function() require("smart-splits").move_cursor_right() end, desc = "Move to right split" }, - { "", function() require("smart-splits").resize_up() end, desc = "Resize split up" }, - { "", function() require("smart-splits").resize_down() end, desc = "Resize split down" }, - { "", function() require("smart-splits").resize_left() end, desc = "Resize split left" }, - { "", function() require("smart-splits").resize_right() end, desc = "Resize split right" }, + { + "", + function() require("smart-splits").move_cursor_left() end, + desc = "Move to left split" + }, + { + "", function() require("smart-splits").move_cursor_down() end, + desc = "Move to below split" + }, + { + "", function() require("smart-splits").move_cursor_up() end, + desc = "Move to above split" + }, + { + "", function() require("smart-splits").move_cursor_right() end, + desc = "Move to right split" + }, + { + "", function() require("smart-splits").resize_up() end, + desc = "Resize split up" + }, + { + "", function() require("smart-splits").resize_down() end, + desc = "Resize split down" + }, + { + "", function() require("smart-splits").resize_left() end, + desc = "Resize split left" + }, + { + "", function() require("smart-splits").resize_right() end, + desc = "Resize split right" + }, }, }