diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | lazy-lock.json | 61 | ||||
-rw-r--r-- | lua/ben/lazy.lua | 1 | ||||
-rw-r--r-- | lua/ben/plugins/fugitive.lua | 28 | ||||
-rw-r--r-- | lua/ben/plugins/lf.lua | 2 | ||||
-rw-r--r-- | lua/ben/plugins/lsp.lua | 246 | ||||
-rw-r--r-- | lua/ben/plugins/lsp/mason.lua | 72 |
7 files changed, 323 insertions, 88 deletions
@@ -4,6 +4,7 @@ ### Lua ### # Compiled Lua sources luac.out +.luarc.json # luarocks build files *.src.rock diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..2018550 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,61 @@ +{ + "Colorizer": { "branch": "master", "commit": "7db0e0dd8adfccab35655f5b6db805caa0fef49a" }, + "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, + "LuaSnip": { "branch": "master", "commit": "2dbef19461198630b3d7c39f414d09fb07d1fdd2" }, + "Nvim-R": { "branch": "master", "commit": "bc548ee07d9631023282003a7dc0b79256522134" }, + "blamer.nvim": { "branch": "master", "commit": "e0d43c11697300eb68f00d69df8b87deb0bf52dc" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "conform.nvim": { "branch": "master", "commit": "cbc5745bf7519acaf3a5cbaaa677fd556aa813d7" }, + "copilot.vim": { "branch": "release", "commit": "49e0348bfb913fae63ca5ddb987a8bccd193da86" }, + "dressing.nvim": { "branch": "master", "commit": "c1179336aaeca82a785cade27e9b7b276af3222e" }, + "elly.vim": { "branch": "main", "commit": "09ec312d46929353222c1b3da89c0dad377b6578" }, + "everforest-nvim": { "branch": "main", "commit": "06a600c4fa49e7a4c44848d14c353ecbaab8eb9f" }, + "friendly-snippets": { "branch": "main", "commit": "69a2c1675b66e002799f5eef803b87a12f593049" }, + "friffle-vim": { "branch": "master", "commit": "afaff65dd80c5598ad18ea8832527f2e728e8cea" }, + "fzf": { "branch": "master", "commit": "687c2741b8d5c0cfcd0b318596cd04914fecf4e9" }, + "fzf-gitignore": { "branch": "master", "commit": "927d54305800570fac4b8ed6f85ae6f40b15331c" }, + "gitsigns.nvim": { "branch": "main", "commit": "c5ff7628e19a47ec14d3657294cc074ecae27b99" }, + "go.nvim": { "branch": "master", "commit": "24d2fa373d55d9900cd4b502a88214dc17e6fab6" }, + "guihua.lua": { "branch": "master", "commit": "9fb6795474918b492d9ab01b1ebaf85e8bf6fe0b" }, + "lazy.nvim": { "branch": "main", "commit": "17d9c93943c692e084dbf203e47e7fa122386d0f" }, + "lf.nvim": { "branch": "master", "commit": "69ab1efcffee6928bf68ac9bd0c016464d9b2c8b" }, + "lspkind.nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" }, + "lualine.nvim": { "branch": "master", "commit": "566b7036f717f3d676362742630518a47f132fff" }, + "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "3ba1b92b771f33256b4969d696b82c8ae7075364" }, + "mason-tool-installer.nvim": { "branch": "main", "commit": "bf0f4f8062d3acbe0afcc61db01a4d19d96310e4" }, + "mason.nvim": { "branch": "main", "commit": "e110bc3be1a7309617cecd77bfe4bf86ba1b8134" }, + "neorg": { "branch": "main", "commit": "a6ec80f455f948e122e669ff6039bc977427b158" }, + "neorg-telescope": { "branch": "main", "commit": "6a7a677c40fa3c348924a4e2a06a513e0b34c056" }, + "nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" }, + "nvim-lint": { "branch": "master", "commit": "2cf9ad095130755d7d87f1730bcf33c91ee822e4" }, + "nvim-lspconfig": { "branch": "master", "commit": "8917d2c830e04bf944a699b8c41f097621283828" }, + "nvim-treesitter": { "branch": "master", "commit": "4e0d1dd91ffacd7d21df7194fbc936a439a29d59" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "19a91a38b02c1c28c14e0ba468d20ae1423c39b2" }, + "nvim-ts-autotag": { "branch": "main", "commit": "8515e48a277a2f4947d91004d9aa92c29fdc5e18" }, + "nvim-web-devicons": { "branch": "master", "commit": "140edfcf25093e8b321d13e154cbce89ee868ca0" }, + "plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" }, + "swhkd-vim": { "branch": "main", "commit": "c104f6cf954cff42dd35cc44957f7c34b647027b" }, + "telescope-yadm.nvim": { "branch": "main", "commit": "23043463b0bb2529bb478eaf816b6445f788aae2" }, + "telescope.nvim": { "branch": "0.1.x", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }, + "toggleterm.nvim": { "branch": "main", "commit": "cbd041d91b90cd3c02df03fe6133208888f8e008" }, + "undotree": { "branch": "main", "commit": "80552a0180b49e5ba072c89ae91ce5d4e3aed36b" }, + "vim-Grammalecte": { "branch": "master", "commit": "a0ce51a77e56151f62ddbfd10e7dec46000f2848" }, + "vim-bling": { "branch": "master", "commit": "5e59a06d14dfc7b44f3d8af109d0a71a107060be" }, + "vim-easy-align": { "branch": "master", "commit": "12dd6316974f71ce333e360c0260b4e1f81169c3" }, + "vim-flog": { "branch": "master", "commit": "bb1fda0cac110aef3f1c0ac00be813377b2b9bf0" }, + "vim-fugitive": { "branch": "master", "commit": "854a8df0d06b8d3fcb30fa7f2b08c62b553eee3b" }, + "vim-gutentags": { "branch": "master", "commit": "aa47c5e29c37c52176c44e61c780032dfacef3dd" }, + "vim-repeat": { "branch": "master", "commit": "24afe922e6a05891756ecf331f39a1f6743d3d5a" }, + "vim-rhubarb": { "branch": "master", "commit": "ee69335de176d9325267b0fd2597a22901d927b1" }, + "vim-searchhi": { "branch": "master", "commit": "6d3d595e84f12b2086b1c77db39da219c1736aa6" }, + "vim-smoothie": { "branch": "master", "commit": "df1e324e9f3395c630c1c523d0555a01d2eb1b7e" }, + "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }, + "vim-table-mode": { "branch": "master", "commit": "4ff8de2ac93431ee6d85a9e04177012752e6abdc" }, + "vimtex": { "branch": "master", "commit": "fe20ab1bd82a23441ac55054afefcd60001947a2" }, + "winresizer": { "branch": "master", "commit": "9bd559a03ccec98a458e60c705547119eb5350f3" }, + "yadm.nvim": { "branch": "master", "commit": "8226580be2b3af9f8cccdbec5c9ba604145cb8b2" } +}
\ No newline at end of file diff --git a/lua/ben/lazy.lua b/lua/ben/lazy.lua index e363abb..46668e4 100644 --- a/lua/ben/lazy.lua +++ b/lua/ben/lazy.lua @@ -12,7 +12,6 @@ end vim.opt.rtp:prepend(lazypath) require("lazy").setup({ { import = "ben.plugins" }, - { import = "ben.plugins.lsp" }, }, { install = { colorscheme = { "everforest" }, diff --git a/lua/ben/plugins/fugitive.lua b/lua/ben/plugins/fugitive.lua index 4b73c42..051a983 100644 --- a/lua/ben/plugins/fugitive.lua +++ b/lua/ben/plugins/fugitive.lua @@ -17,20 +17,20 @@ return { }, config = function() -- Use > and < to fix merge conflicts (keep the cursor in the middle of the screen) - vim.api.nvim_set_keymap("n", ">", "<cmd>diffg //2<cr><cmd>diffupdate<cr>", { noremap = true, silent = true }) - vim.api.nvim_set_keymap("n", "<", "<cmd>diffg //3<cr><cmd>diffupdate<cr>", { noremap = true, silent = true }) + -- vim.api.nvim_set_keymap("n", ">", "<cmd>diffg //2<cr><cmd>diffupdate<cr>", { noremap = true, silent = true }) + -- vim.api.nvim_set_keymap("n", "<", "<cmd>diffg //3<cr><cmd>diffupdate<cr>", { noremap = true, silent = true }) -- Use } and { to force the entire file - vim.api.nvim_set_keymap( - "n", - "}", - "<C-w>h<cmd>Gwrite!<cr><cmd>diffupdate<cr>", - { noremap = true, silent = true } - ) - vim.api.nvim_set_keymap( - "n", - "{", - "<C-w>l<cmd>Gwrite!<cr><cmd>diffupdate<cr>", - { noremap = true, silent = true } - ) + -- vim.api.nvim_set_keymap( + -- "n", + -- "}", + -- "<C-w>h<cmd>Gwrite!<cr><cmd>diffupdate<cr>", + -- { noremap = true, silent = true } + -- ) + -- vim.api.nvim_set_keymap( + -- "n", + -- "{", + -- "<C-w>l<cmd>Gwrite!<cr><cmd>diffupdate<cr>", + -- { noremap = true, silent = true } + -- ) end, } diff --git a/lua/ben/plugins/lf.lua b/lua/ben/plugins/lf.lua index 2e28de2..5c95197 100644 --- a/lua/ben/plugins/lf.lua +++ b/lua/ben/plugins/lf.lua @@ -6,7 +6,7 @@ return { }, config = function() vim.g.lf_netrw = 1 - require("lf").setup({ + local lf = require("lf").setup({ border = "rounded", focus_on_open = true, }) diff --git a/lua/ben/plugins/lsp.lua b/lua/ben/plugins/lsp.lua new file mode 100644 index 0000000..251a459 --- /dev/null +++ b/lua/ben/plugins/lsp.lua @@ -0,0 +1,246 @@ +return { + + { + "williamboman/mason.nvim", + dependencies = { + "williamboman/mason-lspconfig.nvim", + "WhoIsSethDaniel/mason-tool-installer.nvim", + }, + config = function() + -- import mason + local mason = require("mason") + + -- import mason-lspconfig + local mason_lspconfig = require("mason-lspconfig") + local mason_tool_installer = require("mason-tool-installer") + + -- enable mason and configure icons + mason.setup({ + ui = { + icons = { + package_installed = "", + package_pending = "", + package_uninstalled = "", + }, + }, + }) + + mason_lspconfig.setup({ + -- list of servers for mason to install + ensure_installed = { + "ast_grep", -- fallback + "lua_ls", -- lua + "autotools_ls", -- Makefile + "dockerls", -- dockerfiles + "docker_compose_language_service", -- docker-compose + "marksman", -- markdown + "gopls", -- go + "texlab", -- latex + "pyre", -- python + "r_language_server", -- r + "rust_analyzer", -- rust + "mutt_ls", -- mutt + "taplo", -- toml + "yamlls", -- yaml + }, + -- auto-install configured servers (with lspconfig) + automatic_installation = true, + }) + + -- configure mason tool installer + mason_tool_installer.setup({ + ensure_installed = { + "isort", -- python import formatter + "goimports", -- go import formatter + "doctoc", -- markdown table of contents generator + "go-debug-adapter", -- go debugger + "codelldb", -- c/c++ debugger + }, + }) + end, + }, + + { + "neovim/nvim-lspconfig", + dependencies = { "hrsh7th/cmp-nvim-lsp" }, + event = { "BufReadPre", "BufNewFile" }, + config = function() + -- import lspconfig plugin + local lspconfig = require("lspconfig") + + -- import cmp-nvim-lsp plugin + local cmp_nvim_lsp = require("cmp_nvim_lsp") + + local keymap = vim.keymap + + local opts = { noremap = true, silent = true } + local on_attach = function(client, bufnr) + opts.buffer = bufnr + + -- set keybinds + opts.desc = "Show LSP references" + keymap.set("n", "gR", "<cmd>Telescope lsp_references<CR>", opts) -- show definition, references + + opts.desc = "Go to declaration" + keymap.set("n", "gD", vim.lsp.buf.declaration, opts) -- go to declaration + + opts.desc = "Show LSP definitions" + keymap.set("n", "gd", "<cmd>Telescope lsp_definitions<CR>", opts) -- show lsp definitions + + opts.desc = "Show LSP implementations" + keymap.set("n", "gi", "<cmd>Telescope lsp_implementations<CR>", opts) -- show lsp implementations + + opts.desc = "Show LSP type definitions" + keymap.set("n", "gt", "<cmd>Telescope lsp_type_definitions<CR>", opts) -- show lsp type definitions + + opts.desc = "See available code actions" + keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts) -- see available code actions, in visual mode will apply to selection + + opts.desc = "Smart rename" + keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts) -- smart rename + + opts.desc = "Show buffer diagnostics" + keymap.set("n", "<leader>D", "<cmd>Telescope diagnostics bufnr=0<CR>", opts) -- show diagnostics for file + + opts.desc = "Show line diagnostics" + keymap.set("n", "<leader>d", vim.diagnostic.open_float, opts) -- show diagnostics for line + + opts.desc = "Go to previous diagnostic" + keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) -- jump to previous diagnostic in buffer + + opts.desc = "Go to next diagnostic" + keymap.set("n", "]d", vim.diagnostic.goto_next, opts) -- jump to next diagostic in buffer + + opts.desc = "Show documentation for what is under cursor" + keymap.set("n", "K", vim.lsp.buf.hover, opts) -- show documentation for what is under cursor + + opts.desc = "Restart LSP" + keymap.set("n", "<leader>rs", ":LspRestart<CR>", opts) -- mapping to restart lsp if necessary + end + + -- used to enable autocompletion (assign to every lsp server config) + local capabilities = cmp_nvim_lsp.default_capabilities() + + -- change diagnostic symbols in sign column + local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " } + for type, icon in pairs(signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) + end + + -- configure lua server (with special settings) + lspconfig["lua_ls"].setup({ + capabilities = capabilities, + on_attach = on_attach, + settings = { -- custom settings for lua + Lua = { + -- make the language server recognize "vim" global + diagnostics = { + globals = { "vim" }, + }, + workspace = { + -- make language server aware of runtime files + library = { + [vim.fn.expand("$VIMRUNTIME/lua")] = true, + [vim.fn.stdpath("config") .. "/lua"] = true, + }, + }, + }, + }, + }) + + -- configure dockerfile server + lspconfig["dockerls"].setup({ + capabilities = capabilities, + on_attach = on_attach, + }) + + -- configure docker-compose server + lspconfig["docker_compose_language_service"].setup({ + capabilities = capabilities, + on_attach = on_attach, + }) + + -- configure markdown server + lspconfig["marksman"].setup({ + capabilities = capabilities, + on_attach = on_attach, + }) + + -- configure golang server + lspconfig["gopls"].setup({ + capabilities = capabilities, + on_attach = on_attach, + }) + + -- configure LaTeX server + lspconfig["texlab"].setup({ + capabilities = capabilities, + on_attach = on_attach, + }) + + -- configure LaTeX server + lspconfig["texlab"].setup({ + capabilities = capabilities, + on_attach = on_attach, + }) + + -- configure python server + lspconfig["pyre"].setup({ + capabilities = capabilities, + on_attach = on_attach, + }) + + -- configure R server + lspconfig["r_language_server"].setup({ + capabilities = capabilities, + on_attach = on_attach, + }) + + -- configure R server + lspconfig["r_language_server"].setup({ + capabilities = capabilities, + on_attach = on_attach, + }) + + -- configure mutt server + lspconfig["mutt_ls"].setup({ + capabilities = capabilities, + on_attach = on_attach, + }) + + -- configure toml server + lspconfig["taplo"].setup({ + capabilities = capabilities, + on_attach = on_attach, + }) + + -- configure Makefile server + lspconfig["autotools_ls"].setup({ + capabilities = capabilities, + on_attach = on_attach, + }) + + -- configure fallback server + lspconfig["ast_grep"].setup({ + capabilities = capabilities, + on_attach = on_attach, + }) + + -- configure yaml server + lspconfig["yamlls"].setup({ + capabilities = capabilities, + on_attach = on_attach, + settings = { + yaml = { + schemas = { + ["https://json.schemastore.org/github-workflow.json"] = "/.github/workflows/*", + ["../path/relative/to/file.yml"] = "/.github/workflows/*", + ["/path/from/root/of/project"] = "/.github/workflows/*", + }, + }, + }, + }) + end, + }, +} diff --git a/lua/ben/plugins/lsp/mason.lua b/lua/ben/plugins/lsp/mason.lua deleted file mode 100644 index 121509d..0000000 --- a/lua/ben/plugins/lsp/mason.lua +++ /dev/null @@ -1,72 +0,0 @@ -return { - "williamboman/mason.nvim", - dependencies = { - "williamboman/mason-lspconfig.nvim", - "WhoIsSethDaniel/mason-tool-installer.nvim", - }, - config = function() - --import mason - local mason = require("mason") - -- import mason-lspconfig - local mason_lspconfig = require("mason-lspconfig") - - local mason_tool_installer = require("mason-tool-installer") - - -- enable mason and configure icons - mason.setup({ - ui = { - icons = { - package_installed = "", - package_pending = "", - package_uninstalled = "", - }, - }, - }) - mason_lspconfig.setup({ - -- list of servers for mason to install - ensure_installed = { - "bashls", - "cssls", - "diagnosticls", - "dockerls", - "docker_compose_language_service", - "gopls", - "lua_ls", - "texlab", - "zk", - "pyright", - "r_language_server", - "sqls", - }, - -- auto-install configured servers (with lspconfig) - automatic_installation = true, -- not the same as ensure_installed - }) - - mason_tool_installer.setup({ - ensure_installed = { - "mutt-language-server", - "emmet-ls", - -- Linters: - "prettier", - "bibtex-tidy", - "goimports", - "gci", - "golines", - "shfmt", - "latexindent", - "sql-formatter", - "isort", - "black", - "yamlfix", - "stylua", - -- Formatters: - "stylelint", - "markdownlint", - "pylint", - "golangci-lint", - "shellcheck", - }, - }) - - end, -} |