From b6b1c24aa002a20f0c5adde6a63a7107f48b3976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20La=C3=ADn?= Date: Mon, 24 Jul 2023 13:13:24 +0200 Subject: [PATCH] new plugins and changes in nvim configs, changed thunar for nemo as default file explorer, other cache changes for vscode and better discord --- .config/nvim/lazy-lock.json | 40 ++- .config/nvim/lua/config/lazy.lua | 9 + .config/nvim/lua/config/options.lua | 23 ++ .config/nvim/lua/plugins/dap-ui.lua | 26 ++ .config/nvim/lua/plugins/dap-virtual-text.lua | 6 + .config/nvim/lua/plugins/dap.lua | 188 ++++++++++++ .config/nvim/lua/plugins/lspconfig.lua | 281 ++++++++++++++++++ .config/nvim/lua/plugins/null-ls.lua | 33 ++ .config/nvim/lua/plugins/numb.lua | 6 + .config/nvim/lua/plugins/treesitter.lua | 6 + .config/nvim/lua/plugins/which-key.lua | 12 + 11 files changed, 614 insertions(+), 16 deletions(-) create mode 100644 .config/nvim/lua/plugins/dap-ui.lua create mode 100644 .config/nvim/lua/plugins/dap-virtual-text.lua create mode 100644 .config/nvim/lua/plugins/dap.lua create mode 100644 .config/nvim/lua/plugins/lspconfig.lua create mode 100644 .config/nvim/lua/plugins/null-ls.lua create mode 100644 .config/nvim/lua/plugins/numb.lua create mode 100644 .config/nvim/lua/plugins/which-key.lua diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index b9217cc8..9173bb43 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,32 +1,34 @@ { - "LazyVim": { "branch": "main", "commit": "871e7fb0dbe0a9b5bed1a454cd1ee8464b6b9fa4" }, + "LazyVim": { "branch": "main", "commit": "142e6bec209704210db23b3424b4d51896bb206a" }, "LuaSnip": { "branch": "master", "commit": "0b4950a237ce441a6a3a947d501622453f6860ea" }, - "SchemaStore.nvim": { "branch": "main", "commit": "43b2ef9a1b716752dcdcb9fafddfdb871a59051f" }, + "SchemaStore.nvim": { "branch": "main", "commit": "f33af3051c79f084824753f9852ed4db95b43c8d" }, "alpha-nvim": { "branch": "main", "commit": "e4fc5e29b731bdf55d204c5c6a11dc3be70f3b65" }, "blamer.nvim": { "branch": "master", "commit": "f4eb22a9013642c411725fdda945ae45f8d93181" }, - "bufferline.nvim": { "branch": "main", "commit": "d24378edc14a675c820a303b4512af3bbc5761e9" }, + "bufferline.nvim": { "branch": "main", "commit": "99f0932365b34e22549ff58e1bea388465d15e99" }, "catppuccin": { "branch": "main", "commit": "6425df128d46f2db2cccf9aa7a66ca2823c1d153" }, "cinnamon.nvim": { "branch": "master", "commit": "c406ffda3a0302f32c23b24ab756ea20467d6578" }, + "cmake-tools.nvim": { "branch": "master", "commit": "213932932d1fb17d513a40343ce9f7f026197847" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, "copilot-cmp": { "branch": "master", "commit": "c2cdb3c0f5078b0619055af192295830a7987790" }, "copilot.lua": { "branch": "master", "commit": "e48bd7020a98be217d85c006a298656294fd6210" }, + "crates.nvim": { "branch": "main", "commit": "4ce7c51b881e58f1e2f8f437f30e4e583cbac319" }, "dressing.nvim": { "branch": "master", "commit": "39611852fd7bbac117e939a26759bb37361f0c90" }, - "flash.nvim": { "branch": "main", "commit": "7ddeb57f60e2f19ee836aef5dc6cc1d91771f012" }, - "friendly-snippets": { "branch": "main", "commit": "ea84a710262cb2c286d439070bad37d36fd3db25" }, + "flash.nvim": { "branch": "main", "commit": "967117690bd677cb7b6a87f0bc0077d2c0be3a27" }, + "friendly-snippets": { "branch": "main", "commit": "bc38057e513458cb2486b6cd82d365fa294ee398" }, "gitsigns.nvim": { "branch": "main", "commit": "adcf2c7f2f495f5df148683764bf7cba6a70f34c" }, - "glance.nvim": { "branch": "master", "commit": "3e7158ffaaa0fa1f7268df30ae40f24c07b840d1" }, + "glance.nvim": { "branch": "master", "commit": "866d0f8584c129e071d84138c679d39aa9b5684c" }, "glow.nvim": { "branch": "main", "commit": "bbd0473d72a45094495ee5600b5577823543eefe" }, "indent-blankline.nvim": { "branch": "master", "commit": "4541d690816cb99a7fc248f1486aa87f3abce91c" }, - "lazy.nvim": { "branch": "main", "commit": "b7303a68309296fb4809c51ce0bf66722e5dc4f7" }, + "lazy.nvim": { "branch": "main", "commit": "3ad55ae678876516156cca2f361c51f7952a924b" }, "legendary.nvim": { "branch": "master", "commit": "3db15cae08d63bab40d0c38474e368f97414f090" }, "live-server.nvim": { "branch": "main", "commit": "8cae0641cabe8c555311f09dbb0ae36a513a9d5c" }, "lualine.nvim": { "branch": "master", "commit": "05d78e9fd0cdfb4545974a5aa14b1be95a86e9c9" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "828a538ac8419f586c010996aefa5df6eb7c250b" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "e86a4c84ff35240639643ffed56ee1c4d55f538e" }, "mason-nvim-dap.nvim": { "branch": "main", "commit": "e4d56b400e9757b1dc77d620fd3069396e92d5fc" }, - "mason.nvim": { "branch": "main", "commit": "5ad3e113b0c3fde3caba8630599373046f6197e8" }, + "mason.nvim": { "branch": "main", "commit": "3f6b544c75c01549f7a2a9e395e0f1cea42b25dd" }, "mini.ai": { "branch": "main", "commit": "5218ea75e635df78a807bc9d5a7162594fb76d02" }, "mini.bufremove": { "branch": "main", "commit": "7821606e35c1ac931b56d8e3155f45ffe76ee7e5" }, "mini.comment": { "branch": "main", "commit": "877acea5b2a32ff55f808fc0ebe9aa898648318c" }, @@ -35,20 +37,24 @@ "mini.surround": { "branch": "main", "commit": "9d1956b576d7051da3a483b251dfc778121c60db" }, "neo-tree.nvim": { "branch": "v3.x", "commit": "981a43adcca25e7ccc3c589902d49f25e4d48ebc" }, "neoconf.nvim": { "branch": "main", "commit": "08f146d53e075055500dca35e93281faff95716b" }, - "neodev.nvim": { "branch": "main", "commit": "62515f64dfb196e8abe1263e17e2546559e41292" }, - "noice.nvim": { "branch": "main", "commit": "679740982682018a0805a5c813b19e4c7540f7a9" }, + "neodev.nvim": { "branch": "main", "commit": "866b6b6e687a93ba98851a03a74bf6d9211b7299" }, + "noice.nvim": { "branch": "main", "commit": "c7969e3c25530087b3a52128030163280a7cf679" }, "nui.nvim": { "branch": "main", "commit": "9e3916e784660f55f47daa6f26053ad044db5d6a" }, "null-ls.nvim": { "branch": "main", "commit": "db09b6c691def0038c456551e4e2772186449f35" }, + "numb.nvim": { "branch": "master", "commit": "2c89245d1185e02fec1494c45bc765a38b6b40b3" }, "nvim-cmp": { "branch": "main", "commit": "c4e491a87eeacf0408902c32f031d802c7eafce8" }, "nvim-dap": { "branch": "master", "commit": "d17d1bba23ec72a157bd183c57840c39e323f515" }, + "nvim-dap-go": { "branch": "main", "commit": "eab43d63cef832801a701812913e4d1d726725e5" }, + "nvim-dap-python": { "branch": "master", "commit": "37b4cba02e337a95cb62ad1609b3d1dccb2e5d42" }, "nvim-dap-ui": { "branch": "master", "commit": "85b16ac2309d85c88577cd8ee1733ce52be8227e" }, "nvim-dap-virtual-text": { "branch": "master", "commit": "57f1dbd0458dd84a286b27768c142e1567f3ce3b" }, + "nvim-jdtls": { "branch": "master", "commit": "96e3978c3fdae3950f6ccda548775e8b8952f74a" }, "nvim-lspconfig": { "branch": "master", "commit": "dd11ba7b3c8f82d51b6d4dd7d68fce2d78bf78a0" }, "nvim-navic": { "branch": "master", "commit": "9c89730da6a05acfeb6a197e212dfadf5aa60ca0" }, "nvim-notify": { "branch": "master", "commit": "ea9c8ce7a37f2238f934e087c255758659948e0f" }, - "nvim-spectre": { "branch": "master", "commit": "1ef252c1bf569b88e7e2fafde1eb0861d4f06aa3" }, - "nvim-treesitter": { "branch": "master", "commit": "a8ac8419c420f3564e5212ecbeba3283cfa9e78e" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "52f1f3280d9092bfaee5c45be5962fabee3d9654" }, + "nvim-spectre": { "branch": "master", "commit": "3ba6edeea1390457caaf73e96ab9c086ff6f90e9" }, + "nvim-treesitter": { "branch": "master", "commit": "7b04e8b67eec7d92daadf9f0717dd272ddfc81a3" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "ef32a5c24b767d165ed63fd2b24ac8dc52742521" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "7f625207f225eea97ef7a6abe7611e556c396d2f" }, "nvim-web-devicons": { "branch": "master", "commit": "efbfed0567ef4bfac3ce630524a0f6c8451c5534" }, "persistence.nvim": { "branch": "main", "commit": "4b8051c01f696d8849a5cb8afa9767be8db16e40" }, @@ -56,11 +62,13 @@ "presence.nvim": { "branch": "main", "commit": "87c857a56b7703f976d3a5ef15967d80508df6e6" }, "project.nvim": { "branch": "main", "commit": "8c6bad7d22eef1b71144b401c9f74ed01526a4fb" }, "rnvimr": { "branch": "main", "commit": "a89e373330649326a80c2fcafe7b92b5814792f6" }, - "telescope.nvim": { "branch": "master", "commit": "597a3cc889c1d16dc38ae4c61f9b542d5258815f" }, + "rust-tools.nvim": { "branch": "master", "commit": "0cc8adab23117783a0292a0c8a2fbed1005dc645" }, + "telescope.nvim": { "branch": "master", "commit": "1228f3b15ca3d9b95dcb92efda6a3448871030bd" }, "todo-comments.nvim": { "branch": "main", "commit": "09b0b17d824d2d56f02ff15967e8a2499a89c731" }, "tokyonight.nvim": { "branch": "main", "commit": "1ee11019f8a81dac989ae1db1a013e3d582e2033" }, - "trouble.nvim": { "branch": "main", "commit": "20d1b30d6925213abece21d35858a16e11d1e9fc" }, + "trouble.nvim": { "branch": "main", "commit": "0e6703c1d37d2d34ed029ab54f9bd66e3f2ecbf7" }, "typescript.nvim": { "branch": "main", "commit": "de304087e6e49981fde01af8ccc5b21e8519306f" }, + "venv-selector.nvim": { "branch": "main", "commit": "cc312074371aff5b0d8d481b80c9c4de2a5287d7" }, "vim-illuminate": { "branch": "master", "commit": "a2907275a6899c570d16e95b9db5fd921c167502" }, "vim-startuptime": { "branch": "master", "commit": "454b3de856b7bd298700de33d79774ca9b9e3875" }, "vim-wakatime": { "branch": "master", "commit": "018fa9a80c27ccf2a8967b9e27890372e5c2fb4f" }, diff --git a/.config/nvim/lua/config/lazy.lua b/.config/nvim/lua/config/lazy.lua index e50de8a3..12b9fbb6 100644 --- a/.config/nvim/lua/config/lazy.lua +++ b/.config/nvim/lua/config/lazy.lua @@ -19,6 +19,15 @@ require("lazy").setup({ { import = "lazyvim.plugins.extras.dap.core" }, { import = "lazyvim.plugins.extras.formatting.prettier" }, { import = "lazyvim.plugins.extras.util.project" }, + { import = "lazyvim.plugins.extras.lang.python" }, + { import = "lazyvim.plugins.extras.lang.docker" }, + { import = "lazyvim.plugins.extras.lang.go" }, + { import = "lazyvim.plugins.extras.lang.cmake" }, + { import = "lazyvim.plugins.extras.lang.java" }, + { import = "lazyvim.plugins.extras.lang.rust" }, + { import = "lazyvim.plugins.extras.linting.eslint" }, + { import = "lazyvim.plugins.extras.dap.core" }, + { import = "lazyvim.plugins.extras.formatting.prettier" }, --{ import = "lazyvim.plugins.extras.editor.flash" }, -- import/override with your plugins { import = "plugins" }, diff --git a/.config/nvim/lua/config/options.lua b/.config/nvim/lua/config/options.lua index 529878a5..3e199541 100644 --- a/.config/nvim/lua/config/options.lua +++ b/.config/nvim/lua/config/options.lua @@ -46,6 +46,29 @@ if vim.g.neovide then vim.g.neovide_cursor_vfx_mode = "pixiedust" vim.opt.winblend = 20 + + if vim.fn.exists("g:terminal_color_0") == 0 then + vim.api.nvim_set_var("terminal_color_0", '#494D64') + vim.api.nvim_set_var("terminal_color_1", '#ED8796') + vim.api.nvim_set_var("terminal_color_2", '#A6DA95') + vim.api.nvim_set_var("terminal_color_3", '#EED49F') + vim.api.nvim_set_var("terminal_color_4", '#8AADF4') + vim.api.nvim_set_var("terminal_color_5", '#F5BDE6') + vim.api.nvim_set_var("terminal_color_6", '#8BD5CA') + vim.api.nvim_set_var("terminal_color_7", '#B8C0E0') + vim.api.nvim_set_var("terminal_color_8", '#5B6078') + vim.api.nvim_set_var("terminal_color_9", '#ED8796') + vim.api.nvim_set_var("terminal_color_10", '#A6DA95') + vim.api.nvim_set_var("terminal_color_11", '#EED49F') + vim.api.nvim_set_var("terminal_color_12", '#8AADF4') + vim.api.nvim_set_var("terminal_color_13", '#F5BDE6') + vim.api.nvim_set_var("terminal_color_14", '#8BD5CA') + vim.api.nvim_set_var("terminal_color_15", '#B8C0E0') + end + + vim.g.neovide_theme = 'catppuccin-macchiato' end vim.opt.relativenumber = false + +vim.opt.shell = "fish" diff --git a/.config/nvim/lua/plugins/dap-ui.lua b/.config/nvim/lua/plugins/dap-ui.lua new file mode 100644 index 00000000..eebfb2c5 --- /dev/null +++ b/.config/nvim/lua/plugins/dap-ui.lua @@ -0,0 +1,26 @@ +return { + { + "rcarriga/nvim-dap-ui", + -- stylua: ignore + keys = { + { "du", function() require("dapui").toggle({}) end, desc = "Dap UI" }, + { "de", function() require("dapui").eval() end, desc = "Eval", mode = { "n", "v" } }, + }, + lazy = false, + opts = {}, + config = function(_, opts) + local dap = require("dap") + local dapui = require("dapui") + dapui.setup(opts) + dap.listeners.after.event_initialized["dapui_config"] = function() + dapui.open({}) + end + dap.listeners.before.event_terminated["dapui_config"] = function() + dapui.close({}) + end + dap.listeners.before.event_exited["dapui_config"] = function() + dapui.close({}) + end + end, + } +} diff --git a/.config/nvim/lua/plugins/dap-virtual-text.lua b/.config/nvim/lua/plugins/dap-virtual-text.lua new file mode 100644 index 00000000..874c244e --- /dev/null +++ b/.config/nvim/lua/plugins/dap-virtual-text.lua @@ -0,0 +1,6 @@ +return { + { + "theHamsta/nvim-dap-virtual-text", + opts = {}, + } +} diff --git a/.config/nvim/lua/plugins/dap.lua b/.config/nvim/lua/plugins/dap.lua new file mode 100644 index 00000000..67e84596 --- /dev/null +++ b/.config/nvim/lua/plugins/dap.lua @@ -0,0 +1,188 @@ +return { + { + "mfussenegger/nvim-dap", + + dependencies = { + + -- fancy UI for the debugger + { + "rcarriga/nvim-dap-ui", + -- stylua: ignore + keys = { + { "du", function() require("dapui").toggle({}) end, desc = "Dap UI" }, + { "de", function() require("dapui").eval() end, desc = "Eval", mode = { "n", "v" } }, + }, + opts = {}, + config = function(_, opts) + local dap = require("dap") + local dapui = require("dapui") + dapui.setup(opts) + dap.listeners.after.event_initialized["dapui_config"] = function() + dapui.open({}) + end + dap.listeners.before.event_terminated["dapui_config"] = function() + dapui.close({}) + end + dap.listeners.before.event_exited["dapui_config"] = function() + dapui.close({}) + end + end, + }, + + -- virtual text for the debugger + { + "theHamsta/nvim-dap-virtual-text", + opts = {}, + }, + + -- which key integration + { + "folke/which-key.nvim", + optional = true, + opts = { + defaults = { + ["d"] = { name = "+debug" }, + ["da"] = { name = "+adapters" }, + }, + }, + }, + + -- mason.nvim integration + { + "jay-babu/mason-nvim-dap.nvim", + dependencies = "mason.nvim", + cmd = { "DapInstall", "DapUninstall" }, + opts = { + -- Makes a best effort to setup the various debuggers with + -- reasonable debug configurations + automatic_installation = true, + + -- You can provide additional configuration to the handlers, + -- see mason-nvim-dap README for more information + handlers = {}, + + -- You'll need to check that you have the required things installed + -- online, please don't ask me how to install them :) + ensure_installed = { + -- Update this to ensure that you have the debuggers for the langs you want + }, + }, + }, + }, + + lazy = false, + + -- stylua: ignore + keys = { + { + "dB", + function() require("dap").set_breakpoint(vim.fn.input('Breakpoint condition: ')) end, + desc = + "Breakpoint Condition" + }, + { + "db", + function() require("dap").toggle_breakpoint() end, + desc = + "Toggle Breakpoint" + }, + { + "dc", + function() require("dap").continue() end, + desc = + "Continue" + }, + { + "dC", + function() require("dap").run_to_cursor() end, + desc = + "Run to Cursor" + }, + { + "dg", + function() require("dap").goto_() end, + desc = + "Go to line (no execute)" + }, + { + "di", + function() require("dap").step_into() end, + desc = + "Step Into" + }, + { + "dj", + function() require("dap").down() end, + desc = + "Down" + }, + { + "dk", + function() require("dap").up() end, + desc = + "Up" + }, + { + "dl", + function() require("dap").run_last() end, + desc = + "Run Last" + }, + { + "do", + function() require("dap").step_out() end, + desc = + "Step Out" + }, + { + "dO", + function() require("dap").step_over() end, + desc = + "Step Over" + }, + { + "dp", + function() require("dap").pause() end, + desc = + "Pause" + }, + { + "dr", + function() require("dap").repl.toggle() end, + desc = + "Toggle REPL" + }, + { + "ds", + function() require("dap").session() end, + desc = + "Session" + }, + { + "dt", + function() require("dap").terminate() end, + desc = + "Terminate" + }, + { + "dw", + function() require("dap.ui.widgets").hover() end, + desc = + "Widgets" + }, + }, + + config = function() + local Config = require("lazyvim.config") + vim.api.nvim_set_hl(0, "DapStoppedLine", { default = true, link = "Visual" }) + + for name, sign in pairs(Config.icons.dap) do + sign = type(sign) == "table" and sign or { sign } + vim.fn.sign_define( + "Dap" .. name, + { text = sign[1], texthl = sign[2] or "DiagnosticInfo", linehl = sign[3], numhl = sign[3] } + ) + end + end, + } +} diff --git a/.config/nvim/lua/plugins/lspconfig.lua b/.config/nvim/lua/plugins/lspconfig.lua new file mode 100644 index 00000000..82c7d38d --- /dev/null +++ b/.config/nvim/lua/plugins/lspconfig.lua @@ -0,0 +1,281 @@ +return { + { + "neovim/nvim-lspconfig", + opts = { + servers = { + eslint = { + settings = { + -- helps eslint find the eslintrc when it's placed in a subfolder instead of the cwd root + workingDirectory = { mode = "auto" }, + }, + }, + pyright = {}, + ruff_lsp = {}, + neocmake = {}, + dockerls = {}, + docker_compose_language_service = {}, + gopls = { + keys = { + -- Workaround for the lack of a DAP strategy in neotest-go: https://github.com/nvim-neotest/neotest-go/issues/12 + { "td", "lua require('dap-go').debug_test()", desc = "Debug Nearest (Go)" }, + }, + settings = { + gopls = { + gofumpt = true, + codelenses = { + gc_details = false, + generate = true, + regenerate_cgo = true, + run_govulncheck = true, + test = true, + tidy = true, + upgrade_dependency = true, + vendor = true, + }, + hints = { + assignVariableTypes = true, + compositeLiteralFields = true, + compositeLiteralTypes = true, + constantValues = true, + functionTypeParameters = true, + parameterNames = true, + rangeVariableTypes = true, + }, + analyses = { + fieldalignment = true, + nilness = true, + unusedparams = true, + unusedwrite = true, + useany = true, + }, + usePlaceholders = true, + completeUnimported = true, + staticcheck = true, + directoryFilters = { "-.git", "-.vscode", "-.idea", "-.vscode-test", "-node_modules" }, + semanticTokens = true, + }, + }, + }, + jdtls = { + -- stylua: ignore + keys = { + { + "co", + function() require("jdtls").organize_imports() end, + desc = + "Organize Imports", + }, + { + "cR", + function() require("jdtls").rename_file() end, + desc = + "Rename File", + }, + { + "cxv", + function() require("jdtls").extract_variable() end, + desc = + "Extract Variable", + }, + { + "cxv", + function() require("jdtls").extract_variable({ visual = true }) end, + mode = "v", + desc = + "Extract Variable", + }, + { + "cxc", + function() require("jdtls").extract_constant() end, + desc = + "Extract Constant", + }, + { + "cxc", + function() require("jdtls").extract_constant({ visual = true }) end, + mode = "v", + desc = + "Extract Constant", + }, + { + "cxm", + function() require("jdtls").extract_method({ visual = true }) end, + mode = "v", + desc = + "Extract Method", + }, + }, + }, + rust_analyzer = { + keys = { + { "K", "RustHoverActions", desc = "Hover Actions (Rust)" }, + { "cR", "RustCodeAction", desc = "Code Action (Rust)" }, + { "dr", "RustDebuggables", desc = "Run Debuggables (Rust)" }, + }, + settings = { + ["rust-analyzer"] = { + cargo = { + allFeatures = true, + loadOutDirsFromCheck = true, + runBuildScripts = true, + }, + -- Add clippy lints for Rust. + checkOnSave = { + allFeatures = true, + command = "clippy", + extraArgs = { "--no-deps" }, + }, + procMacro = { + enable = true, + ignored = { + ["async-trait"] = { "async_trait" }, + ["napi-derive"] = { "napi" }, + ["async-recursion"] = { "async_recursion" }, + }, + }, + }, + }, + }, + taplo = { + keys = { + { + "K", + function() + if vim.fn.expand("%:t") == "Cargo.toml" and require("crates").popup_available() then + require("crates").show_popup() + else + vim.lsp.buf.hover() + end + end, + desc = "Show Crate Documentation", + }, + }, + }, + }, + tsserver = { + keys = { + { "co", "TypescriptOrganizeImports", desc = "Organize Imports" }, + { "cR", "TypescriptRenameFile", desc = "Rename File" }, + }, + settings = { + typescript = { + format = { + indentSize = vim.o.shiftwidth, + convertTabsToSpaces = vim.o.expandtab, + tabSize = vim.o.tabstop, + }, + }, + javascript = { + format = { + indentSize = vim.o.shiftwidth, + convertTabsToSpaces = vim.o.expandtab, + tabSize = vim.o.tabstop, + }, + }, + completions = { + completeFunctionCalls = true, + }, + }, + }, + }, + setup = { + rust_analyzer = function(_, opts) + local rust_tools_opts = require("lazyvim.util").opts("rust-tools.nvim") + require("rust-tools").setup(vim.tbl_deep_extend("force", rust_tools_opts or {}, { server = opts })) + return true + end, + ruff_lsp = function() + require("lazyvim.util").on_attach(function(client, _) + if client.name == "ruff_lsp" then + -- Disable hover in favor of Pyright + client.server_capabilities.hoverProvider = false + end + end) + end, + + gopls = function(_, opts) + -- workaround for gopls not supporting semanticTokensProvider + -- https://github.com/golang/go/issues/54531#issuecomment-1464982242 + require("lazyvim.util").on_attach(function(client, _) + if client.name == "gopls" then + if not client.server_capabilities.semanticTokensProvider then + local semantic = client.config.capabilities.textDocument.semanticTokens + client.server_capabilities.semanticTokensProvider = { + full = true, + legend = { + tokenTypes = semantic.tokenTypes, + tokenModifiers = semantic.tokenModifiers, + }, + range = true, + } + end + end + end) + -- end workaround + end, + + jdtls = function() + -- The lspconfig configuration for jdtls contains two useful items: + -- 1. The list of filetypes on which to match. + -- 2. Custom method for finding the root for a java project. + local lsp_config = require("lspconfig.server_configurations.jdtls").default_config + local find_java_project_root = lsp_config.root_dir + local filetypes = lsp_config.filetypes + + -- Attach jdtls for the proper filetypes (i.e. java). + -- Existing server will be reused if the root_dir matches. + vim.api.nvim_create_autocmd("FileType", { + group = vim.api.nvim_create_augroup("MyJdtls", { clear = true }), + pattern = filetypes, + callback = function() + local fname = vim.api.nvim_buf_get_name(0) + local root_dir = find_java_project_root(fname) + local project_name = root_dir and vim.fs.basename(root_dir) + local cmd = { "jdtls" } + if project_name then + local jdtls_cache_dir = vim.fs.joinpath(vim.fn.stdpath("cache"), "jdtls", project_name) + vim.list_extend(cmd, { + "-configuration", + vim.fs.joinpath(jdtls_cache_dir, "config"), + "-data", + vim.fs.joinpath(jdtls_cache_dir, "workspace"), + }) + end + require("jdtls").start_or_attach({ + cmd = cmd, + root_dir = root_dir, + }) + require("which-key").register({ c = { x = { name = "Extract" } } }, { prefix = "" }) + end, + }) + + return true -- avoid duplicate servers + end, + + tsserver = function(_, opts) + require("typescript").setup({ server = opts }) + return true + end, + + eslint = function() + vim.api.nvim_create_autocmd("BufWritePre", { + callback = function(event) + if not require("lazyvim.plugins.lsp.format").enabled() then + -- exit early if autoformat is not enabled + return + end + + local client = vim.lsp.get_active_clients({ bufnr = event.buf, name = "eslint" })[1] + if client then + local diag = vim.diagnostic.get(event.buf, + { namespace = vim.lsp.diagnostic.get_namespace(client.id) }) + if #diag > 0 then + vim.cmd("EslintFixAll") + end + end + end, + }) + end, + }, + }, +} diff --git a/.config/nvim/lua/plugins/null-ls.lua b/.config/nvim/lua/plugins/null-ls.lua new file mode 100644 index 00000000..0043e9df --- /dev/null +++ b/.config/nvim/lua/plugins/null-ls.lua @@ -0,0 +1,33 @@ +return { + { + "jose-elias-alvarez/null-ls.nvim", + opts = function(_, opts) + if type(opts.sources) == "table" then + local nls = require("null-ls") + vim.list_extend(opts.sources, { + nls.builtins.code_actions.gomodifytags, + nls.builtins.code_actions.impl, + nls.builtins.formatting.gofumpt, + nls.builtins.formatting.goimports_reviser, + }) + end + + local nls = require("null-ls") + opts.sources = opts.sources or {} + vim.list_extend(opts.sources, { + nls.builtins.diagnostics.hadolint, + }) + + local nls = require("null-ls") + opts.sources = opts.sources or {} + vim.list_extend(opts.sources, { + nls.builtins.diagnostics.cmake_lint, + }) + + table.insert(opts.sources, require("typescript.extensions.null-ls.code-actions")) + + local nls = require("null-ls") + table.insert(opts.sources, nls.builtins.formatting.prettierd) + end, + } +} diff --git a/.config/nvim/lua/plugins/numb.lua b/.config/nvim/lua/plugins/numb.lua new file mode 100644 index 00000000..fa73adc0 --- /dev/null +++ b/.config/nvim/lua/plugins/numb.lua @@ -0,0 +1,6 @@ +return { + { + "nacro90/numb.nvim", + lazy = false + } +} diff --git a/.config/nvim/lua/plugins/treesitter.lua b/.config/nvim/lua/plugins/treesitter.lua index a1cf4c54..f68deced 100644 --- a/.config/nvim/lua/plugins/treesitter.lua +++ b/.config/nvim/lua/plugins/treesitter.lua @@ -25,6 +25,9 @@ return { "gitcommit", "gitignore", "go", + "gomod", + "gowork", + "gosum", "groovy", "hjson", "http", @@ -41,6 +44,7 @@ return { "prisma", "python", "r", + "ron", "rasi", "regex", "ruby", @@ -54,6 +58,8 @@ return { "vim", "vue", "yaml", + "ninja", + "rst" }) end, }, diff --git a/.config/nvim/lua/plugins/which-key.lua b/.config/nvim/lua/plugins/which-key.lua new file mode 100644 index 00000000..963b8645 --- /dev/null +++ b/.config/nvim/lua/plugins/which-key.lua @@ -0,0 +1,12 @@ +return { + { + "folke/which-key.nvim", + optional = true, + opts = { + defaults = { + ["d"] = { name = "+debug" }, + ["da"] = { name = "+adapters" }, + }, + }, + } +}