diff options
| -rw-r--r-- | flake.lock | 98 | ||||
| -rw-r--r-- | flake.nix | 21 | ||||
| -rw-r--r-- | lsp/basedpyright.lua | 23 | ||||
| -rw-r--r-- | lsp/clangd.lua | 21 | ||||
| -rw-r--r-- | lsp/qmlls.lua | 5 | ||||
| -rw-r--r-- | lsp/rust-analyzer.lua | 25 | ||||
| -rw-r--r-- | lsp/verible.lua | 8 | ||||
| -rw-r--r-- | lua/config/lsp.lua | 39 | ||||
| -rw-r--r-- | lua/config/options.lua | 3 | ||||
| -rw-r--r-- | lua/config/plugins/completion.lua | 9 | ||||
| -rw-r--r-- | lua/config/plugins/extra.lua | 69 | ||||
| -rw-r--r-- | lua/config/plugins/formatting.lua | 2 | ||||
| -rw-r--r-- | lua/config/plugins/init.lua | 1 | ||||
| -rw-r--r-- | lua/config/plugins/snippets.lua | 13 | ||||
| -rw-r--r-- | lua/config/plugins/ui.lua | 28 |
15 files changed, 288 insertions, 77 deletions
@@ -3,11 +3,11 @@ "flake-compat": { "flake": false, "locked": { - "lastModified": 1733328505, - "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=", + "lastModified": 1747046372, + "narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=", "owner": "edolstra", "repo": "flake-compat", - "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", + "rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885", "type": "github" }, "original": { @@ -19,11 +19,11 @@ "flake-compat_2": { "flake": false, "locked": { - "lastModified": 1696426674, - "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "lastModified": 1747046372, + "narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=", "owner": "edolstra", "repo": "flake-compat", - "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885", "type": "github" }, "original": { @@ -40,11 +40,11 @@ ] }, "locked": { - "lastModified": 1741352980, - "narHash": "sha256-+u2UunDA4Cl5Fci3m7S643HzKmIDAe+fiXrLqYsR2fs=", + "lastModified": 1759362264, + "narHash": "sha256-wfG0S7pltlYyZTM+qqlhJ7GMw2fTF4mLKCIVhLii/4M=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "f4330d22f1c5d2ba72d3d22df5597d123fdb60a9", + "rev": "758cf7296bee11f1706a574c77d072b8a7baa881", "type": "github" }, "original": { @@ -53,27 +53,6 @@ "type": "github" } }, - "flake-parts_2": { - "inputs": { - "nixpkgs-lib": [ - "neovim-nightly-overlay", - "hercules-ci-effects", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1741352980, - "narHash": "sha256-+u2UunDA4Cl5Fci3m7S643HzKmIDAe+fiXrLqYsR2fs=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "f4330d22f1c5d2ba72d3d22df5597d123fdb60a9", - "type": "github" - }, - "original": { - "id": "flake-parts", - "type": "indirect" - } - }, "git-hooks": { "inputs": { "flake-compat": "flake-compat_2", @@ -84,11 +63,11 @@ ] }, "locked": { - "lastModified": 1742649964, - "narHash": "sha256-DwOTp7nvfi8mRfuL1escHDXabVXFGT1VlPD1JHrtrco=", + "lastModified": 1759523803, + "narHash": "sha256-PTod9NG+i3XbbnBKMl/e5uHDBYpwIWivQ3gOWSEuIEM=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "dcf5072734cb576d2b0c59b2ac44f5050b5eac82", + "rev": "cfc9f7bb163ad8542029d303e599c0f7eee09835", "type": "github" }, "original": { @@ -121,18 +100,21 @@ }, "hercules-ci-effects": { "inputs": { - "flake-parts": "flake-parts_2", + "flake-parts": [ + "neovim-nightly-overlay", + "flake-parts" + ], "nixpkgs": [ "neovim-nightly-overlay", "nixpkgs" ] }, "locked": { - "lastModified": 1742014779, - "narHash": "sha256-I6fG1zrfdLFcp/imGZElig0BJO3YU0QEXLgvwWoOpJ8=", + "lastModified": 1758022363, + "narHash": "sha256-ENUhCRWgSX4ni751HieNuQoq06dJvApV/Nm89kh+/A0=", "owner": "hercules-ci", "repo": "hercules-ci-effects", - "rev": "524637ef84c177661690b924bf64a1ce18072a2c", + "rev": "1a3667d33e247ad35ca250698d63f49a5453d824", "type": "github" }, "original": { @@ -152,11 +134,11 @@ "treefmt-nix": "treefmt-nix" }, "locked": { - "lastModified": 1743207056, - "narHash": "sha256-Ds/eKU6M8WuP7U+y13041tdqz24/frq2yP9CohyVlDQ=", + "lastModified": 1759795531, + "narHash": "sha256-iY43k/GpJJqv5WmHsJpDsOZsOqb2qydM7wWnpJygiUk=", "owner": "nix-community", "repo": "neovim-nightly-overlay", - "rev": "d9eee4fbfd7fe14b9a2019079ecde37e59fc109e", + "rev": "df3d6d30529e6f4d2c1709914cb3e6e3896dd64e", "type": "github" }, "original": { @@ -168,11 +150,11 @@ "neovim-src": { "flake": false, "locked": { - "lastModified": 1743202909, - "narHash": "sha256-cNSjnWG1vtkWLT5hvmiesuGmOppb1R6Z9V11hv2mMew=", + "lastModified": 1759794827, + "narHash": "sha256-eN26ZJbzwuv0fvc33v4vR5hESWr/+TzJUXaKfdUQx+I=", "owner": "neovim", "repo": "neovim", - "rev": "cb31663663b9be92dd9c2fbe06ccea88625b2fca", + "rev": "1c4e0e50449d95465e7f256d39fea54b307e0e33", "type": "github" }, "original": { @@ -183,11 +165,11 @@ }, "nixCats": { "locked": { - "lastModified": 1743207292, - "narHash": "sha256-Hf23aM/FRGCvT/oNyPUZ2kw9j2ptpkBo3UzdO2kORXs=", + "lastModified": 1759730664, + "narHash": "sha256-boRlBQ/c4CaHsK/z04QL6+t81mcar37Io94HBX2GflY=", "owner": "BirdeeHub", "repo": "nixCats-nvim", - "rev": "7cf13e3215570450a432cf32a5ae7dd82a4f63e1", + "rev": "77dffad8235eb77684fcb7599487c8e9f23d5b8f", "type": "github" }, "original": { @@ -198,11 +180,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1743076231, - "narHash": "sha256-yQugdVfi316qUfqzN8JMaA2vixl+45GxNm4oUfXlbgw=", + "lastModified": 1759632233, + "narHash": "sha256-krgZxGAIIIKFJS+UB0l8do3sYUDWJc75M72tepmVMzE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "6c5963357f3c1c840201eda129a99d455074db04", + "rev": "d7f52a7a640bc54c7bb414cca603835bf8dd4b10", "type": "github" }, "original": { @@ -214,11 +196,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1743076231, - "narHash": "sha256-yQugdVfi316qUfqzN8JMaA2vixl+45GxNm4oUfXlbgw=", + "lastModified": 1759632233, + "narHash": "sha256-krgZxGAIIIKFJS+UB0l8do3sYUDWJc75M72tepmVMzE=", "owner": "nixos", "repo": "nixpkgs", - "rev": "6c5963357f3c1c840201eda129a99d455074db04", + "rev": "d7f52a7a640bc54c7bb414cca603835bf8dd4b10", "type": "github" }, "original": { @@ -247,11 +229,11 @@ "plugins-multicursor-nvim": { "flake": false, "locked": { - "lastModified": 1746157028, - "narHash": "sha256-ZV4/QolvzaxV0SoPwO3Orf3HCJGD2+J15WKRUe0Hauw=", + "lastModified": 1758976684, + "narHash": "sha256-QhYUwFGYXoeXr2dRraHvpYx4z/7R9TyL9OC2sGmIAMY=", "owner": "jake-stewart", "repo": "multicursor.nvim", - "rev": "0e00ce4c272e3191b5e07cab36bd49aa32fca675", + "rev": "0c6ceae228bf209e8b8717df9de500770c4e7022", "type": "github" }, "original": { @@ -294,11 +276,11 @@ ] }, "locked": { - "lastModified": 1743081648, - "narHash": "sha256-WRAylyYptt6OX5eCEBWyTwOEqEtD6zt33rlUkr6u3cE=", + "lastModified": 1758728421, + "narHash": "sha256-ySNJ008muQAds2JemiyrWYbwbG+V7S5wg3ZVKGHSFu8=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "29a3d7b768c70addce17af0869f6e2bd8f5be4b7", + "rev": "5eda4ee8121f97b218f7cc73f5172098d458f1d1", "type": "github" }, "original": { @@ -138,6 +138,10 @@ nodejs-slim ]; + c = [ + clang-tools + ]; + lua = [ lua-language-server stylua @@ -149,6 +153,10 @@ nixfmt-rfc-style ]; + python = [ basedpyright ]; + + qml = [ kdePackages.qtdeclarative ]; + rust = [ # NOTE: required to find project root # NOTE: for now unused, so commented out @@ -163,6 +171,11 @@ typescript-language-server ]; + verilog = [ + verible + verilator + ]; + debug = [ lldb ]; @@ -231,6 +244,11 @@ ]; completion = [ blink-cmp ]; + snippets = [ + luasnip + friendly-snippets + ]; + # NOTE: On NeoVim 0.11+ nvim-lspconfig is not required due to native API lsp = [ lazydev-nvim ]; @@ -265,6 +283,9 @@ oil-nvim yanky-nvim which-key-nvim + + # SuperCollider + scnvim ]; }; }; diff --git a/lsp/basedpyright.lua b/lsp/basedpyright.lua new file mode 100644 index 0000000..79ff625 --- /dev/null +++ b/lsp/basedpyright.lua @@ -0,0 +1,23 @@ +return { + cmd = { "basedpyright-langserver", "--stdio" }, + filetypes = { "python" }, + root_markers = { + "pyrightconfig.json", + "pyproject.toml", + "setup.py", + "setup.cfg", + "requirements.txt", + "Pipfile", + ".git", + }, + + settings = { + basedpyright = { + analysis = { + autoSearchPaths = true, + useLibraryCodeForTypes = true, + diagnosticMode = "openFilesOnly", + }, + }, + }, +} diff --git a/lsp/clangd.lua b/lsp/clangd.lua new file mode 100644 index 0000000..9aced07 --- /dev/null +++ b/lsp/clangd.lua @@ -0,0 +1,21 @@ +return { + cmd = { "clangd" }, + filetypes = { "c", "cpp", "objc", "objcpp", "cuda" }, + root_markers = { + ".clangd", + ".clang-tidy", + ".clang-format", + "compile_commands.json", + "compile_flags.txt", + "configure.ac", -- AutoTools + ".git", + }, + capabilities = { + textDocument = { + completion = { + editsNearCursor = true, + }, + }, + offsetEncoding = { "utf-8", "utf-16" }, + }, +} diff --git a/lsp/qmlls.lua b/lsp/qmlls.lua new file mode 100644 index 0000000..92dc83b --- /dev/null +++ b/lsp/qmlls.lua @@ -0,0 +1,5 @@ +return { + cmd = { "qmlls", "-E" }, + root_markers = { ".qmlls.ini", ".git" }, + filetypes = { "qml", "qmljs" }, +} diff --git a/lsp/rust-analyzer.lua b/lsp/rust-analyzer.lua index 51f5037..78ed2c5 100644 --- a/lsp/rust-analyzer.lua +++ b/lsp/rust-analyzer.lua @@ -1,8 +1,33 @@ +local serverReady = {} + return { cmd = { "rust-analyzer" }, root_markers = { "Cargo.toml" }, filetypes = { "rust" }, + capabilities = { + experimental = { + serverStatusNotification = true, + }, + }, + + handlers = { + ["experimental/serverStatus"] = function(_, result, ctx) + -- Try to fix inlay hints not being shown on start of + if result.quiescent and not serverReady[ctx.client_id] then + for _, bufnr in ipairs(vim.lsp.get_buffers_by_client_id(ctx.client_id)) do + -- Re-enable inlay hints so they are refreshed + if vim.lsp.inlay_hint.is_enabled() then + vim.lsp.inlay_hint.enable(false, { bufnr = bufnr }) + vim.lsp.inlay_hint.enable(true, { bufnr = bufnr }) + end + + serverReady[ctx.client_id] = true + end + end + end, + }, + settings = { ["rust-analyzer"] = { checkOnSave = { command = "clippy" }, diff --git a/lsp/verible.lua b/lsp/verible.lua new file mode 100644 index 0000000..2361b8f --- /dev/null +++ b/lsp/verible.lua @@ -0,0 +1,8 @@ +return { + cmd = { "verible-verilog-ls" }, + filetypes = { "verilog", "systemverilog" }, + root_markers = { + "verilator.f", + ".git", + }, +} diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua index 413e06f..71f3dba 100644 --- a/lua/config/lsp.lua +++ b/lua/config/lsp.lua @@ -6,12 +6,20 @@ vim.diagnostic.config({ }) vim.lsp.enable({ + "clangd", + "lua-language-server", "nixd", + "basedpyright", + + "qmlls", + "rust-analyzer", + "verible", + "angular-language-server", "biome", "typescript-language-server", @@ -27,3 +35,34 @@ vim.api.nvim_create_autocmd({ "BufReadPost", "BufNewFile" }, { vim.treesitter.start(nil, "angular") end, }) + +vim.api.nvim_create_autocmd("LspAttach", { + callback = function(args) + local buffer = args.buf + local client = vim.lsp.get_client_by_id(args.data.client_id) + if client then + -- Keybindings + local map = vim.keymap.set + local opts = { buffer = buffer } + + map("n", "<leader>cr", vim.lsp.buf.rename, opts) + map("n", "gd", vim.lsp.buf.definition, opts) + map("n", "gD", vim.lsp.buf.declaration, opts) + map("n", "gI", vim.lsp.buf.implementation, opts) + map("n", "gy", vim.lsp.buf.type_definition, opts) + map("n", "gr", vim.lsp.buf.references, opts) + + map("n", "K", function() + return vim.lsp.buf.hover() + end, opts) + + map("n", "gK", function() + return vim.lsp.buf.signature_help() + end, opts) + + map({ "n", "i" }, "<C-;>", function() + return vim.lsp.buf.signature_help() + end, opts) + end + end, +}) diff --git a/lua/config/options.lua b/lua/config/options.lua index 43bf110..6208be7 100644 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -60,6 +60,9 @@ map("n", "N", "Nzzzv", { desc = "Previous Search Result" }) -- Reset search highlight on ESC map("n", "<Esc>", "<cmd>nohlsearch<CR>", { desc = "Reset search highlight" }) +-- Window related binds +map("n", "<C-w>d", "<C-w>c", { desc = "[D]elete [W]indow" }) + -- Buffer related binds map("n", "<leader>bd", "<cmd>bdelete<CR>", { desc = "[D]elete [B]uffer" }) diff --git a/lua/config/plugins/completion.lua b/lua/config/plugins/completion.lua index 2b7e69d..7acef49 100644 --- a/lua/config/plugins/completion.lua +++ b/lua/config/plugins/completion.lua @@ -37,6 +37,13 @@ return { }, completion = { + list = { + selection = { + auto_insert = false, + preselect = false, + }, + }, + documentation = { auto_show = true, auto_show_delay_ms = 500, @@ -45,6 +52,8 @@ return { ghost_text = { enabled = true }, }, + snippets = { preset = "luasnip" }, + cmdline = { completion = { ghost_text = { enabled = false }, diff --git a/lua/config/plugins/extra.lua b/lua/config/plugins/extra.lua index 2f7bf9c..19a7042 100644 --- a/lua/config/plugins/extra.lua +++ b/lua/config/plugins/extra.lua @@ -11,29 +11,19 @@ return { -- Keybindings would be a lot better as <localleader> local map = vim.keymap.set - -- NOTE: this required for "repeatable" commands - -- I'd like to use `2<localleader>cn` for example (and that doesn't work out of box) - local map_rep = function(modes, bind, action) - map(modes, bind, function() - for _ = 1, vim.v.count1, 1 do - action() - end - end) - end - -- stylua: ignore start map({ "n", "x" }, "<localleader><localleader>", function() mc.clearCursors() end) map({ "n", "x" }, "<localleader>R", function() mc.restoreCursors() end) - map_rep({ "n", "x" }, "<localleader>j", function() mc.lineAddCursor(1) end) - map_rep({ "n", "x" }, "<localleader>k", function() mc.lineAddCursor(-1) end) - map_rep({ "n", "x" }, "<localleader>J", function() mc.lineSkipCursor(1) end) - map_rep({ "n", "x" }, "<localleader>K", function() mc.lineSkipCursor(-1) end) + map({ "n", "x" }, "<localleader>j", function() mc.lineAddCursor(1) end) + map({ "n", "x" }, "<localleader>k", function() mc.lineAddCursor(-1) end) + map({ "n", "x" }, "<localleader>J", function() mc.lineSkipCursor(1) end) + map({ "n", "x" }, "<localleader>K", function() mc.lineSkipCursor(-1) end) - map_rep({ "n", "x" }, "<localleader>cn", function() mc.matchAddCursor(1) end) - map_rep({ "n", "x" }, "<localleader>cN", function() mc.matchAddCursor(-1) end) - map_rep({ "n", "x" }, "<localleader>cs", function() mc.matchSkipCursor(1) end) - map_rep({ "n", "x" }, "<localleader>cS", function() mc.matchSkipCursor(-1) end) + map({ "n", "x" }, "<localleader>cn", function() mc.matchAddCursor(1) end) + map({ "n", "x" }, "<localleader>cN", function() mc.matchAddCursor(-1) end) + map({ "n", "x" }, "<localleader>cs", function() mc.matchSkipCursor(1) end) + map({ "n", "x" }, "<localleader>cS", function() mc.matchSkipCursor(-1) end) map({ "n", "x" }, "<localleader>cM", mc.matchAllAddCursors) map("x", "<localleader>m", mc.matchCursors) map("x", "<localleader>s", mc.splitCursors) @@ -108,6 +98,9 @@ return { { "<leader>gh", group = "hunk" }, { "<leader>S", group = "surround" }, }, + + { "<leader>x", group = "extra" }, + { "<leader>xS", group = "supercollider" }, }) end, }, @@ -122,4 +115,44 @@ return { { "-", "<CMD>Oil<CR>", { desc = "Open parent directory" } }, }, }, + { + "scnvim", + -- NOTE: this plugin is broken when try to lazyload + lazy = false, + after = function(_) + local scnvim = require("scnvim") + local map = scnvim.map + local map_expr = scnvim.map_expr + + scnvim.setup({ + ensure_installed = true, + keymaps = { + ["<M-CR>"] = { + map("editor.send_block", { "i", "n" }), + map("editor.send_selection", "x"), + }, + ["<C-CR>"] = map("editor.send_line", { "i", "n" }), + ["<C-k>"] = map("signature.show", { "i", "n" }), + + ["<F12>"] = map("sclang.hard_stop", { "i", "n", "x" }), + }, + }) + + vim.api.nvim_create_augroup("my.scnvim", { clear = true }) + vim.api.nvim_create_autocmd("InsertEnter", { + pattern = "*.scd", + group = "my.scnvim", + once = true, + callback = function() + -- Loading snippets to LuaSnip + require("luasnip").add_snippets("supercollider", require("scnvim/utils").get_snippets()) + end, + }) + end, + keys = { + { "<leader>xSs", "<CMD>SCNvimStart<CR>", desc = "Start SuperCollider" }, + { "<leader>xSS", "<CMD>SCNvimStop<CR>", desc = "Stop SuperCollider" }, + { "<leader>xSr", "<CMD>SCNvimRecompile<CR>", desc = "Recompile SuperCollider sclang" }, + }, + }, } diff --git a/lua/config/plugins/formatting.lua b/lua/config/plugins/formatting.lua index 98bbe06..93b7db7 100644 --- a/lua/config/plugins/formatting.lua +++ b/lua/config/plugins/formatting.lua @@ -10,6 +10,8 @@ return { lua = { "stylua" }, nix = { "nixfmt" }, rust = { "rustfmt", lsp_format = "fallback" }, + verilog = { "verible" }, + systemverilog = { "verible" }, html = { "prettierd" }, htmlangular = { "prettierd" }, diff --git a/lua/config/plugins/init.lua b/lua/config/plugins/init.lua index f7c44fd..3c372a0 100644 --- a/lua/config/plugins/init.lua +++ b/lua/config/plugins/init.lua @@ -54,6 +54,7 @@ require("lze").load({ { import = "config.plugins.treesitter" }, { import = "config.plugins.mini" }, { import = "config.plugins.completion" }, + { import = "config.plugins.snippets" }, { import = "config.plugins.formatting" }, { import = "config.plugins.git" }, { import = "config.plugins.debug" }, diff --git a/lua/config/plugins/snippets.lua b/lua/config/plugins/snippets.lua new file mode 100644 index 0000000..5a37b0c --- /dev/null +++ b/lua/config/plugins/snippets.lua @@ -0,0 +1,13 @@ +return { + { + "luasnip", + dep_of = { "blink.cmp" }, + load = function(name) + vim.cmd.packadd(name) + vim.cmd.packadd("friendly-snippets") + end, + after = function(_) + require("luasnip.loaders.from_vscode").lazy_load() + end, + }, +} diff --git a/lua/config/plugins/ui.lua b/lua/config/plugins/ui.lua index e552f0e..593efc7 100644 --- a/lua/config/plugins/ui.lua +++ b/lua/config/plugins/ui.lua @@ -4,7 +4,7 @@ return { event = "DeferredUIEnter", after = function(_) require("bufferline").setup({ - highlights = require("catppuccin.groups.integrations.bufferline").get(), + highlights = require("catppuccin.special.bufferline").get_theme(), }) end, }, @@ -17,6 +17,32 @@ return { options = { theme = "catppuccin", }, + + sections = { + lualine_a = { "mode" }, + lualine_b = { "branch", "diff", "diagnostics" }, + lualine_c = { "filename" }, + + lualine_x = { + -- SuperCollider status bar (server status) + { + function() + -- NOTE: for some reason LuaLS doesn't find `gsub` in string o.O + ---@diagnostic disable-next-line + return require("scnvim.statusline").get_server_status():gsub("%%", "%%%%") + end, + cond = function() + return vim.bo.filetype == "supercollider" + end, + }, + + "filetype", + "encoding", + "fileformat", + }, + lualine_y = { "progress" }, + lualine_z = { "location" }, + }, }) end, }, |
