diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 0000000..fd51329 --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,15 @@ +ignore = { + "631", -- max_line_length +} +read_globals = { + "vim", + "describe", + "it", + "assert" +} +files['tests'] = { + ignore = { + '121', -- Setting a read-only global variable. + '122', -- Setting a read-only field of a global variable. + } +} diff --git a/lazy-lock.json b/lazy-lock.json index dd59f13..37a7b9e 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,68 +1,69 @@ { - "ChatGPT.nvim": { "branch": "main", "commit": "df53728e05129278d6ea26271ec086aa013bed90" }, + "ChatGPT.nvim": { "branch": "main", "commit": "f081338f07216a46d3915ce46c1fcb083bcb5016" }, "LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" }, "animation.nvim": { "branch": "main", "commit": "fb77091ab72ec9971aee0562e7081182527aaa6a" }, "barbecue.nvim": { "branch": "main", "commit": "cd7e7da622d68136e13721865b4d919efd6325ed" }, - "bufferline.nvim": { "branch": "main", "commit": "99337f63f0a3c3ab9519f3d1da7618ca4f91cffe" }, + "bufferline.nvim": { "branch": "main", "commit": "2e3c8cc5a57ddd32f1edd2ffd2ccb10c09421f6c" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, - "codeium.nvim": { "branch": "main", "commit": "d3b88eb3aa1de6da33d325c196b8a41da2bcc825" }, - "conform.nvim": { "branch": "master", "commit": "9b26e81c4292106e68dda3e7b64473434fd5b3e0" }, - "copilot-cmp": { "branch": "master", "commit": "72fbaa03695779f8349be3ac54fa8bd77eed3ee3" }, - "copilot.lua": { "branch": "master", "commit": "f7612f5af4a7d7615babf43ab1e67a2d790c13a6" }, - "dashboard-nvim": { "branch": "master", "commit": "5346d023afc4bfc7ff63d05c70bcdb0784bb657a" }, - "dressing.nvim": { "branch": "master", "commit": "572314728cb1ce012e825fd66331f52c94acac12" }, - "emmet-vim": { "branch": "master", "commit": "def5d57a1ae5afb1b96ebe83c4652d1c03640f4d" }, - "friendly-snippets": { "branch": "main", "commit": "e11b09bf10706bb74e16e4c3d11b2274d62e687f" }, - "gitsigns.nvim": { "branch": "main", "commit": "76927d14d3fbd4ba06ccb5246e79d93b5442c188" }, + "codeium.nvim": { "branch": "main", "commit": "f6a2ef32a9e923cb0104a19d3e426b0e40e49505" }, + "conform.nvim": { "branch": "master", "commit": "ae213f5169d5d0c6abbe76e1438d932772fc1657" }, + "copilot-cmp": { "branch": "master", "commit": "b6e5286b3d74b04256d0a7e3bd2908eabec34b44" }, + "copilot.lua": { "branch": "master", "commit": "86537b286f18783f8b67bccd78a4ef4345679625" }, + "dashboard-nvim": { "branch": "master", "commit": "fabf5feec96185817c732d47d363f34034212685" }, + "dressing.nvim": { "branch": "master", "commit": "71349f24c6e07b39f33600985843c289ca735308" }, + "emmet-vim": { "branch": "master", "commit": "3fb2f63799e1922f7647ed9ff3b32154031a76ee" }, + "friendly-snippets": { "branch": "main", "commit": "00ebcaa159e817150bd83bfe2d51fa3b3377d5c4" }, + "gitsigns.nvim": { "branch": "main", "commit": "0b04035bb7b3c83e999b9676e2fb46fd0aa9f910" }, "heirline.nvim": { "branch": "master", "commit": "0d797435e54645a5f98bad7ad6046aac1ef95c1e" }, "img-clip.nvim": { "branch": "main", "commit": "fc30500c35663aa1762697f5aba31d43b86028f0" }, - "indent-blankline.nvim": { "branch": "master", "commit": "d98f537c3492e87b6dc6c2e3f66ac517528f406f" }, - "lazy.nvim": { "branch": "main", "commit": "b0ba3f9399bf48c86abaa4db1a40bd0b681d5018" }, - "llm.nvim": { "branch": "main", "commit": "6a90755cfabb56ab99c919b1323e26b5c429f6fb" }, + "indent-blankline.nvim": { "branch": "master", "commit": "65e20ab94a26d0e14acac5049b8641336819dfc7" }, + "lazy.nvim": { "branch": "main", "commit": "9a374a0fb4d3ac42dac4a129d4bead7252473c77" }, + "llm.nvim": { "branch": "main", "commit": "9832a149bdcf0709433ca9c2c3a1c87460e98d13" }, "lsp_signature.nvim": { "branch": "master", "commit": "e92b4e7073345b2a30a56b20db3d541a9aa2771e" }, - "lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" }, + "lualine.nvim": { "branch": "master", "commit": "544dd1583f9bb27b393f598475c89809c4d5e86b" }, "markdown-preview.nvim": { "branch": "master", "commit": "9becceee5740b7db6914da87358a183ad11b2049" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "9ae570e206360e47d30b4c35a4550c165f4ea7b7" }, "mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" }, "middleclass": { "branch": "master", "commit": "9fab4d5bca67262614960960ca35c4740eb2be2c" }, - "mini.comment": { "branch": "main", "commit": "a4b7e46deb9ad2feb8902cc5dbf087eced112ee5" }, - "mini.hipatterns": { "branch": "main", "commit": "0a72439dbded766af753a3e7ec0a5b21d0f8ada0" }, - "mini.pairs": { "branch": "main", "commit": "04f58f2545ed80ac3b52dd4826e93f33e15b2af6" }, + "mini.comment": { "branch": "main", "commit": "c8406379987c321ecdef9f53e1ca741a55002104" }, + "mini.hipatterns": { "branch": "main", "commit": "427712c754bfdccd8da7073576cd8e2586c0fe93" }, + "mini.pairs": { "branch": "main", "commit": "40261dfcec7623cd57be3c3beb50fa73f2650cdf" }, "monokai-pro.nvim": { "branch": "master", "commit": "2bad2a92fe0ff6c8581d33a853a1b17592b83239" }, "neo-tree-diagnostics.nvim": { "branch": "main", "commit": "e00434c3cf8637bcaf70f65c2b9d82b0cc9bd7dc" }, "neo-tree.nvim": { "branch": "main", "commit": "8c75e8a2949cd6cd35525799200a8d34471ee9eb" }, - "noice.nvim": { "branch": "main", "commit": "29c7f030b0920e2f17263a9ab8742cde144b9140" }, - "none-ls.nvim": { "branch": "main", "commit": "8691504118b252d64fc5023a104aedd100ab754a" }, + "noice.nvim": { "branch": "main", "commit": "29b63a8fac55efe31bc2e03318012ed222e87212" }, + "none-ls.nvim": { "branch": "main", "commit": "2cde745aadc2c36f6860a77a556494870675771a" }, "nui.nvim": { "branch": "main", "commit": "a0fd35fcbb4cb479366f1dc5f20145fd718a3733" }, "nvim": { "branch": "main", "commit": "a1439ad7c584efb3d0ce14ccb835967f030450fe" }, - "nvim-cmp": { "branch": "main", "commit": "5260e5e8ecadaf13e6b82cf867a909f54e15fd07" }, + "nvim-cmp": { "branch": "main", "commit": "d818fd0624205b34e14888358037fb6f5dc51234" }, "nvim-jdtls": { "branch": "master", "commit": "a5c6f38f8151d7b4f5b32c005a95022fa66f4c9d" }, "nvim-lightbulb": { "branch": "master", "commit": "02aacd93b9b2367e6dbdd20f43b525f701faf834" }, - "nvim-lint": { "branch": "master", "commit": "1a3a8d047bc01f1760ae4a0f5e80f111ea222e67" }, - "nvim-lspconfig": { "branch": "master", "commit": "d1ab6b6051976b04948e127b0f302a465b1394d6" }, + "nvim-lint": { "branch": "master", "commit": "efc6fc83f0772283e064c53a8f9fb5645bde0bc0" }, + "nvim-lspconfig": { "branch": "master", "commit": "1ea7c6126a1aa0121098e4f16c04d5dde1a4ba22" }, "nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" }, "nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" }, "nvim-scrollbar": { "branch": "main", "commit": "d09f14aa16c9f2748e77008f9da7b1f76e4e7b85" }, - "nvim-treesitter": { "branch": "master", "commit": "fc9ee79f64b18bf431e862c2462d4f76d488492a" }, - "nvim-treesitter-context": { "branch": "master", "commit": "5efba33af0f39942e426340da7bc15d7dec16474" }, - "nvim-ts-autotag": { "branch": "main", "commit": "6eb4120a1aadef07ac312f1c4bc6456712220007" }, - "nvim-ts-context-commentstring": { "branch": "main", "commit": "cb064386e667def1d241317deed9fd1b38f0dc2e" }, + "nvim-treesitter": { "branch": "master", "commit": "667b9dbbfa2d0071c5677c429ddcf89fb931b53f" }, + "nvim-treesitter-context": { "branch": "master", "commit": "2aba92ceb1479485953007f4d5adf34d0b66917e" }, + "nvim-ts-autotag": { "branch": "main", "commit": "1624866a1379fc1861797f0ed05899a9c1d2ff61" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "6b5f95aa4d24f2c629a74f2c935c702b08dbde62" }, "nvim-ufo": { "branch": "main", "commit": "a5390706f510d39951dd581f6d2a972741b3fa26" }, "nvim-web-devicons": { "branch": "master", "commit": "5b9067899ee6a2538891573500e8fd6ff008440f" }, - "persistence.nvim": { "branch": "main", "commit": "ad538bfd5336f1335cdb6fd4e0b0eebfa6e12f32" }, + "persistence.nvim": { "branch": "main", "commit": "c45ff862b53ce07a853a753fb0b33e148dbb99d2" }, "plenary.nvim": { "branch": "master", "commit": "50012918b2fc8357b87cff2a7f7f0446e47da174" }, "promise-async": { "branch": "main", "commit": "38a4575da9497326badd3995e768b4ccf0bb153e" }, "rainbow-delimiters.nvim": { "branch": "master", "commit": "12b1a1e095d968887a17ef791c2edb78d7595d46" }, + "render-markdown": { "branch": "main", "commit": "3578523f497a8ad3b4a356d1e54e609838ce0922" }, "statuscol.nvim": { "branch": "main", "commit": "483b9a596dfd63d541db1aa51ee6ee9a1441c4cc" }, - "telescope.nvim": { "branch": "master", "commit": "dfa230be84a044e7f546a6c2b0a403c739732b86" }, - "tokyonight.nvim": { "branch": "main", "commit": "67c6050e1ca41260c919236a098ba278472c7520" }, + "tailwindcss-colorizer-cmp.nvim": { "branch": "main", "commit": "3d3cd95e4a4135c250faf83dd5ed61b8e5502b86" }, + "telescope.nvim": { "branch": "master", "commit": "79552ef8488cb492e0f9d2bf3b4e808f57515e35" }, + "tokyonight.nvim": { "branch": "main", "commit": "1471dab694ad88351185758bb4275624d8b798ec" }, "vim-bbye": { "branch": "master", "commit": "903f5eb17f72ebf7b0b1524bbb792c0b36761af6" }, - "vim-illuminate": { "branch": "master", "commit": "5eeb7951fc630682c322e88a9bbdae5c224ff0aa" }, "vim-visual-multi": { "branch": "master", "commit": "1c9207b28c8898ab01b54e6d6b61b0b820a814bc" }, - "which-key.nvim": { "branch": "main", "commit": "4b7167f8fb2dba3d01980735e3509e172c024c29" }, + "which-key.nvim": { "branch": "main", "commit": "c4689ab39c1f51cac447893b05bb0266a7af1ed7" }, "windows.nvim": { "branch": "main", "commit": "c7492552b23d0ab30325e90b56066ec51242adc8" } -} \ No newline at end of file +} diff --git a/lua/beastvim/features/lsp/codelens.lua b/lua/beastvim/features/lsp/codelens.lua new file mode 100644 index 0000000..cc07fa0 --- /dev/null +++ b/lua/beastvim/features/lsp/codelens.lua @@ -0,0 +1,28 @@ +local Utils = require("beastvim.utils") + +---@class LspCodeLensOptions +---@field enabled boolean + +---@class beastvim.features.lsp.codelens +local M = {} + +setmetatable(M, { + __call = function(m, ...) + return m.setup(...) + end, +}) + +---@param opts LspCodeLensOptions +function M.setup(opts) + if opts.enabled then + Utils.lsp.on_support_methods("textDocument/codeLens", function(client, buffer) + vim.lsp.codelens.refresh() + vim.api.nvim_create_autocmd({ "BufEnter", "CursorHold", "InsertLeave" }, { + buffer = buffer, + callback = vim.lsp.codelens.refresh, + }) + end) + end +end + +return M diff --git a/lua/beastvim/features/lsp/diagnostics.lua b/lua/beastvim/features/lsp/diagnostics.lua index 9299a0d..730ca61 100644 --- a/lua/beastvim/features/lsp/diagnostics.lua +++ b/lua/beastvim/features/lsp/diagnostics.lua @@ -55,7 +55,7 @@ function M.setup(opts) local map = Utils.safe_keymap_set map("n", "td", function() M.toggle() - end, { desc = "Toggle LSP inlay hints" }) + end, { desc = "Toggle LSP diagnostics" }) end function M.toggle(value) diff --git a/lua/beastvim/features/lsp/init.lua b/lua/beastvim/features/lsp/init.lua index 7d272b9..bfe40a4 100644 --- a/lua/beastvim/features/lsp/init.lua +++ b/lua/beastvim/features/lsp/init.lua @@ -1,6 +1,7 @@ local Utils = require("beastvim.utils") ---@class LspServer +---@field enabled? boolean ---@field keys? LazyKeysSpec ---@field capabilities? table ---@field on_attach? fun(client, bufnr) @@ -11,12 +12,14 @@ local Utils = require("beastvim.utils") ---@field capabilities? table ---@field diagnostics? LspDiagnosticsOptions ---@field inlay_hints? LspInlayHintsOptions +---@field codelens? LspCodeLensOptions ---@class Lsp ---@field keymaps beastvim.features.lsp.keymaps ---@field navic beastvim.features.lsp.navic ---@field diagnostics beastvim.features.lsp.diagnostics ---@field inlay_hints beastvim.features.lsp.inlay_hints +---@field codelens beastvim.features.lsp.codelens ---@field ui beastvim.features.lsp.ui local M = {} @@ -44,6 +47,9 @@ function M.setup(opts) -- Inlay Hints M.inlay_hints.setup(opts.inlay_hints) + -- Codelens + M.codelens.setup(opts.codelens) + -- Keymaps Utils.lsp.on_attach(function(client, bufnr) M.keymaps(client, bufnr) @@ -107,10 +113,12 @@ function M.setup(opts) local ensure_installed = {} for server, server_opts in pairs(servers) do if server_opts then - if not vim.tbl_contains(available, server) then - setup(server) - else - ensure_installed[#ensure_installed + 1] = server + if server_opts.enabled ~= false then + if not vim.tbl_contains(available, server) then + setup(server) + else + ensure_installed[#ensure_installed + 1] = server + end end end end diff --git a/lua/beastvim/features/lsp/inlay_hints.lua b/lua/beastvim/features/lsp/inlay_hints.lua index 60f7ba0..96552ff 100644 --- a/lua/beastvim/features/lsp/inlay_hints.lua +++ b/lua/beastvim/features/lsp/inlay_hints.lua @@ -14,16 +14,18 @@ setmetatable(M, { ---@param opts LspInlayHintsOptions function M.setup(opts) - Utils.lsp.on_support_methods("textDocument/inlayHint", function(client, buffer) - if vim.api.nvim_buf_is_valid(buffer) and vim.bo[buffer].buftype == "" then - M.toggle(buffer, true) - end - end) + if opts.enabled then + Utils.lsp.on_support_methods("textDocument/inlayHint", function(_, buffer) + if vim.api.nvim_buf_is_valid(buffer) and vim.bo[buffer].buftype == "" then + M.toggle(buffer, true) + end + end) - local map = Utils.safe_keymap_set - map("n", "th", function() - M.toggle() - end, { desc = "Toggle LSP inlay hints" }) + local map = Utils.safe_keymap_set + map("n", "th", function() + M.toggle() + end, { desc = "Toggle LSP inlay hints" }) + end end function M.toggle(buf, value) diff --git a/lua/beastvim/features/lsp/keymaps.lua b/lua/beastvim/features/lsp/keymaps.lua index 7a12ac3..bb699e7 100644 --- a/lua/beastvim/features/lsp/keymaps.lua +++ b/lua/beastvim/features/lsp/keymaps.lua @@ -14,25 +14,25 @@ function M.get() { "ld", "Telescope lsp_document_diagnostics", desc = "Document Diagnostics" }, { "lw", "Telescope lsp_workspace_diagnostics", desc = "Workspace Diagnostics" }, -- stylua: ignore - { "lh", function() vim.lsp.inlay_hint(0, nil) end,desc = "Toggle inlay hints"}, { "li", "LspInfo", desc = "Info" }, { "lI", "LspInstallInfo", desc = "Installer Info" }, { "lj", "lua vim.lsp.diagnostic.goto_next()", desc = "Next Diagnostic" }, { "lk", "lua vim.lsp.diagnostic.goto_prev()", desc = "Prev Diagnostic" }, - { "ll", "lua vim.lsp.codelens.run()", desc = "CodeLens Action" }, + { "ll", vim.lsp.codelens.run, desc = "Run CodeLens" }, + { "lc", vim.lsp.codelens.refresh, desc = "Refresh & Display Codelens", mode = { "n" } }, { "lq", "lua vim.lsp.diagnostic.set_loclist()", desc = "Quickfix" }, { "lr", "lua vim.lsp.buf.rename()", desc = "Rename" }, { "ls", "Telescope lsp_document_symbols", desc = "Document Symbols" }, { "lS", "Telescope lsp_dynamic_workspace_symbols", desc = "Workspace Symbols" }, -- Goto - { "gd", "Telescope lsp_definitions", desc = "Go to definition" }, - { "gr", "Telescope lsp_references", desc = "Go to references" }, - { "gi", "Telescope lsp_implementations", desc = "Go to implementations" }, + { "gd", "Telescope lsp_definitions", desc = "Definition" }, + { "gr", "Telescope lsp_references", desc = "References" }, + { "gi", "Telescope lsp_implementations", desc = "Implementations" }, { "K", "lua vim.lsp.buf.hover()", desc = "Hover" }, - { "", "lua vim.lsp.buf.signature_help()", mode = "i", desc = "Signature Help" }, - { "gl", "lua vim.diagnostic.open_float()", desc = "Show diagnostics" }, - { "]d", "lua vim.diagnostic.goto_prev({buffer=0})", desc = "Prev Diagnostic" }, - { "[d", "lua vim.diagnostic.goto_next({buffer=0})", desc = "Next Diagnostic" }, + { "", vim.lsp.buf.signature_help, mode = "i", desc = "Signature Help" }, + { "gl", vim.diagnostic.open_float, desc = "Show diagnostics" }, + { "[d", vim.diagnostic.goto_prev, desc = "Prev Diagnostic" }, + { "]d", vim.diagnostic.goto_next, desc = "Next Diagnostic" }, { "lq", "lua vim.diagnostic.setloclist()", desc = "Quickfix" }, } end @@ -46,7 +46,7 @@ function M.resolve(bufnr) local opts = Utils.plugin.opts("nvim-lspconfig") local clients if vim.fn.has("nvim-0.11") == 1 then - clients = vim.lsp.get_clients({bufnr = bufnr}) + clients = vim.lsp.get_clients({ bufnr = bufnr }) else clients = vim.lsp.get_active_clients({ bufnr = bufnr }) end diff --git a/lua/beastvim/features/lsp/lang/docker.lua b/lua/beastvim/features/lsp/lang/docker.lua index b978701..efc0bcb 100644 --- a/lua/beastvim/features/lsp/lang/docker.lua +++ b/lua/beastvim/features/lsp/lang/docker.lua @@ -34,4 +34,13 @@ return { }) end, }, + + { + "mfussenegger/nvim-lint", + opts = { + linters_by_ft = { + dockerfile = { "hadolint" }, + }, + }, + }, } diff --git a/lua/beastvim/features/lsp/lang/python.lua b/lua/beastvim/features/lsp/lang/python.lua index 3835b63..aa507ec 100644 --- a/lua/beastvim/features/lsp/lang/python.lua +++ b/lua/beastvim/features/lsp/lang/python.lua @@ -20,6 +20,7 @@ return { opts = { servers = { pyright = { + enabled = false, capabilities = function() -- Disable the hint of pyright as it coincides with ruff_lsp. local capabilities = vim.lsp.protocol.make_client_capabilities() @@ -57,6 +58,47 @@ return { }, }, }, + basedpyright = { + enabled = true, + settings = { + basedpyright = { + analysis = { + autoImportCompletions = true, + autoSearchPaths = true, + diagnosticMode = "workspace", + -- These diagnostics are useless, therefore disable them. + diagnosticSeverityOverrides = { + reportArgumentType = "none", + reportAttributeAccessIssue = "none", + reportCallIssue = "none", + reportFunctionMemberAccess = "none", + reportGeneralTypeIssues = "none", + reportIncompatibleMethodOverride = "none", + reportIncompatibleVariableOverride = "none", + reportIndexIssue = "none", + reportOptionalMemberAccess = "none", + reportOptionalSubscript = "none", + reportPrivateImportUsage = "none", + }, + indexing = true, + inlayHints = { + functionReturnTypes = true, + variableTypes = true, + }, + typeCheckingMode = "off", -- Pyright diagnostics is bloody slow + useLibraryCodeForTypes = true, + }, + }, + }, + root_dir = { + "pyproject.toml", + "setup.py", + "setup.cfg", + "requirements.txt", + "Pipfile", + "pyrightconfig.json", + }, + }, ruff_lsp = { keys = { { diff --git a/lua/beastvim/features/lsp/lang/typescript.lua b/lua/beastvim/features/lsp/lang/typescript.lua index 3322cd1..c257d51 100644 --- a/lua/beastvim/features/lsp/lang/typescript.lua +++ b/lua/beastvim/features/lsp/lang/typescript.lua @@ -94,6 +94,17 @@ return { ["graphql"] = { "prettier" }, ["handlebars"] = { "prettier" }, }, + formatters = { + prettier = { + command = "prettier", + args = { + "--print-width", + "150", + "--stdin-filepath", + "$FILENAME", + }, + }, + }, }, }, } diff --git a/lua/beastvim/features/neo-tree/init.lua b/lua/beastvim/features/neo-tree/init.lua index e4441a9..e10bf44 100644 --- a/lua/beastvim/features/neo-tree/init.lua +++ b/lua/beastvim/features/neo-tree/init.lua @@ -56,6 +56,8 @@ local config = { mappings = { ["<1-LeftMouse>"] = "open", ["l"] = "open", + [""] = "none", + ["P"] = { "toggle_preview", config = { use_float = false } }, }, }, filesystem = { diff --git a/lua/beastvim/lazy.lua b/lua/beastvim/lazy.lua index 577ba05..5193459 100644 --- a/lua/beastvim/lazy.lua +++ b/lua/beastvim/lazy.lua @@ -20,8 +20,8 @@ require("lazy").setup({ { import = "beastvim.features.lsp.lang.go", enabled = true }, { import = "beastvim.features.lsp.lang.docker", enabled = true }, { import = "beastvim.features.lsp.lang.dotnet", enabled = false }, - { import = "beastvim.features.lsp.lang.tailwind", enabled = false }, - { import = "beastvim.features.lsp.lang.dot", enabled = true }, + { import = "beastvim.features.lsp.lang.tailwind", enabled = true }, + { import = "beastvim.features.lsp.lang.dot", enabled = false }, }, defaults = { lazy = true, diff --git a/lua/beastvim/plugins/aisync.lua b/lua/beastvim/plugins/aisync.lua index 152ccd5..c52ad39 100644 --- a/lua/beastvim/plugins/aisync.lua +++ b/lua/beastvim/plugins/aisync.lua @@ -115,7 +115,7 @@ return { "jackMort/ChatGPT.nvim", cmd = { "ChatGPTActAs", "ChatGPT" }, opts = { - api_key_cmd = "pass show OpenAI/SignalLab", + api_key_cmd = "pass show OpenAI/Rockship", openai_edit_params = { -- model = "gpt-4-1106-preview", model = "gpt-3.5-turbo", diff --git a/lua/beastvim/plugins/coding.lua b/lua/beastvim/plugins/coding.lua index 418d636..b95a3a0 100644 --- a/lua/beastvim/plugins/coding.lua +++ b/lua/beastvim/plugins/coding.lua @@ -124,10 +124,10 @@ return { }, -- comments - { "JoosepAlviste/nvim-ts-context-commentstring", lazy = true }, + { "JoosepAlviste/nvim-ts-context-commentstring", lazy = false }, { "echasnovski/mini.comment", - event = "VeryLazy", + event = "BufEnter", opts = { options = { custom_commentstring = function() diff --git a/lua/beastvim/plugins/colorscheme.lua b/lua/beastvim/plugins/colorscheme.lua index f380ac1..e6ceebd 100644 --- a/lua/beastvim/plugins/colorscheme.lua +++ b/lua/beastvim/plugins/colorscheme.lua @@ -14,7 +14,7 @@ return { "loctvl842/monokai-pro.nvim", lazy = false, priority = 1000, - keys = { { "C", "MonokaiProSelect", desc = "Select Moonokai pro filter" } }, + keys = { { "C", "MonokaiProSelect", desc = "Select Monokai pro filter" } }, opts = { transparent_background = false, devicons = true, diff --git a/lua/beastvim/plugins/editor.lua b/lua/beastvim/plugins/editor.lua index 29f1481..9ec883c 100644 --- a/lua/beastvim/plugins/editor.lua +++ b/lua/beastvim/plugins/editor.lua @@ -6,11 +6,16 @@ return { "folke/which-key.nvim", event = "VeryLazy", opts = { - plugins = { spelling = true }, - window = { - margin = { 1, 0, 2, 0 }, -- extra window margin [top, right, bottom, left] - padding = { 1, 0, 1, 2 }, -- extra window padding [top, right, bottom, left] - winblend = 5, -- value between 0-100 0 for fully opaque and 100 for fully transparent + plugins = { + spelling = { enabled = true }, + presets = { operators = false, motions = false }, + }, + delay = function(ctx) + return ctx.plugin and 0 or 100 + end, + win = { + padding = { 1, 2 }, -- extra window padding [top/bottom, right/left] + wo = { winblend = 5 }, }, layout = { height = { min = 3, max = 25 }, -- min and max height of the columns @@ -18,22 +23,71 @@ return { spacing = 5, -- spacing between columns align = "center", -- align columns left, center or right }, - defaults = { + sort = { "group", "alphanum" }, + icons = { + mappings = true, + rules = { + { pattern = "dashboard", icon = "🦁", color = "red" }, + { pattern = "find", icon = " ", color = "cyan" }, + { pattern = "close", icon = "󰅙", color = "red" }, + { pattern = "monokai", icon = "", color = "yellow" }, + { pattern = "explorer", icon = "󱏒", color = "green" }, + { pattern = "format and save", icon = "󱣪", color = "green" }, + { pattern = "save", icon = "󰆓", color = "green" }, + { pattern = "zoom", icon = "", color = "gray" }, + { pattern = "split.*vertical", icon = "󰤼", color = "gray" }, + { pattern = "split.*horizontal", icon = "󰤻", color = "gray" }, + { pattern = "lsp", icon = "󰒋", color = "cyan" }, + { pattern = "chatgpt", icon = "󰚩", color = "azure" }, + { pattern = "markdown", icon = "", color = "green" }, + { pattern = "diagnostic", icon = "", color = "red" }, + { pattern = "definition", icon = "󰇀", color = "purple" }, + { pattern = "implement", icon = "󰳽", color = "purple" }, + { pattern = "reference", icon = "󰆽", color = "purple" }, + -- Group [h] + { pattern = "blame", icon = "", color = "yellow" }, + { pattern = "diff", icon = "", color = "green" }, + { pattern = "hunk change", icon = "", color = "yellow" }, + { pattern = "reset", icon = "", color = "gray" }, + { pattern = "stage", icon = "", color = "green" }, + { pattern = "undo", icon = "", color = "gray" }, + { pattern = "hunk", icon = "󰊢", color = "red" }, + { pattern = "branch", icon = "", color = "red" }, + { pattern = "commit", icon = "", color = "green" }, + -- Group [g] + { pattern = "word", icon = "", color = "gray" }, + { pattern = "first line", icon = "", color = "gray" }, + { pattern = "comment", icon = "󰅺", color = "cyan" }, + { pattern = "cycle backwards", icon = "󰾹", color = "gray" }, + { pattern = "selection", icon = "󰒉", color = "gray" }, + }, + }, + defaults = {}, + spec = { mode = { "n", "v" }, - ["g"] = { name = "+Git" }, - ["s"] = { name = "+Session" }, - ["c"] = { name = "+ChatGPT" }, - ["l"] = { name = "+LSP" }, - ["h"] = { name = "+Hunk" }, - ["f"] = { name = "+Fold" }, - ["g"] = { name = "+Goto" }, - ["s"] = { name = "+Search" }, + { "g", group = "+Git" }, + { "s", group = "+Session" }, + { "c", group = "+ChatGPT" }, + { "l", group = "+LSP" }, + { "h", group = "+Hunk" }, + { "t", group = "+Toggle" }, + { "m", group = "+Markdown" }, + { "f", group = "+Fold" }, + { "g", group = "+Goto" }, + { "s", group = "+Search" }, + }, + triggers = { + { "", mode = { "n", "v" } }, + { "[", group = "prev" }, + { "]", group = "next" }, + { "f", mode = { "n" } }, -- fold group + { "s", mode = { "n" } }, -- search group + { "g", mode = { "n", "v" } }, -- search group }, }, config = function(_, opts) local wk = require("which-key") wk.setup(opts) - wk.register(opts.defaults) end, }, @@ -62,6 +116,9 @@ return { desc = "Explorer Float (root dir)", }, }, + deactivate = function() + vim.cmd([[Neotree close]]) + end, opts = require("beastvim.features.neo-tree"), init = function() vim.g.neo_tree_remove_legacy_commands = 1 @@ -324,15 +381,14 @@ return { -- { "gr", "Telescope lsp_references", desc = "Go to references" }, -- { "gi", "Telescope lsp_implementations", desc = "Go to implementations" }, -- search - { "sb", "Telescope git_branches", desc = "Checkout branch" }, - { "sc", "Telescope colorscheme", desc = "Colorscheme" }, - { "sh", "Telescope help_tags", desc = "Find Help" }, - { "sM", "Telescope man_pages", desc = "Man Pages" }, - { "sr", "Telescope oldfiles", desc = "Open Recent File" }, - { "sR", "Telescope registers", desc = "Registers" }, - { "sk", "Telescope keymaps", desc = "Keymaps" }, - { "sC", "Telescope commands", desc = "Commands" }, - { "sH", "Telescope highlights", desc = "Highlight Groups" }, + { "sc", "Telescope colorscheme", desc = "Search Colorscheme" }, + { "sh", "Telescope help_tags", desc = "Search Help" }, + { "sM", "Telescope man_pages", desc = "Search Man Pages" }, + { "sr", "Telescope oldfiles", desc = "Search Recent File" }, + { "sR", "Telescope registers", desc = "Search Registers" }, + { "sk", "Telescope keymaps", desc = "Search Keymaps" }, + { "sC", "Telescope commands", desc = "Search Commands" }, + { "sH", "Telescope highlights", desc = "Search Highlight Groups" }, -- Git { "go", "Telescope git_status", desc = "Open changed file" }, { "gb", "Telescope git_branches", desc = "Checkout branch" }, @@ -351,58 +407,4 @@ return { { "d", "Bdelete!", desc = "Close Buffer" }, }, }, - - -- TODO: Remove this when upgrading Neovim to version >= 0.10.0. - -- references - { - "RRethy/vim-illuminate", - event = { "BufReadPost", "BufNewFile", "BufWritePre" }, - opts = { - filetypes_denylist = { - "dirvish", - "fugitive", - "neo-tree", - "alpha", - "NvimTree", - "neo-tree", - "dashboard", - "TelescopePrompt", - "TelescopeResult", - "DressingInput", - "neo-tree-popup", - "markdown", - "", - }, - delay = 200, - large_file_cutoff = 2000, - large_file_overrides = { - providers = { "lsp" }, - }, - }, - config = function(_, opts) - require("illuminate").configure(opts) - - local function map(key, dir, buffer) - vim.keymap.set("n", key, function() - require("illuminate")["goto_" .. dir .. "_reference"](false) - end, { desc = dir:sub(1, 1):upper() .. dir:sub(2) .. " Reference", buffer = buffer }) - end - - map("]]", "next") - map("[[", "prev") - - -- also set it after loading ftplugins, since a lot overwrite [[ and ]] - vim.api.nvim_create_autocmd("FileType", { - callback = function() - local buffer = vim.api.nvim_get_current_buf() - map("]]", "next", buffer) - map("[[", "prev", buffer) - end, - }) - end, - keys = { - { "]]", desc = "Next Reference" }, - { "[[", desc = "Prev Reference" }, - }, - }, } diff --git a/lua/beastvim/plugins/linting.lua b/lua/beastvim/plugins/linting.lua index eb331f3..4eb4c1a 100644 --- a/lua/beastvim/plugins/linting.lua +++ b/lua/beastvim/plugins/linting.lua @@ -1,16 +1,98 @@ +-- Ref: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/plugins/linting.lua +local Utils = require("beastvim.utils") + return { { "mfussenegger/nvim-lint", event = { "BufReadPost", "BufNewFile", "BufWritePre" }, opts = { + -- Event to trigger linters + events = { "BufWritePost", "BufReadPost", "InsertLeave" }, linters_by_ft = { - markdown = { "vale" }, + -- markdown = { "vale" }, lua = { "luacheck" }, + -- Use the "*" filetype to run linters on all filetypes. + -- ['*'] = { 'global linter' }, + -- Use the "_" filetype to run linters on filetypes that don't have other linters configured. + -- ['_'] = { 'fallback linter' }, + -- ["*"] = { "typos" }, + }, + ---@type table + linters = { + -- -- Example of using selene only when a selene.toml file is present + -- selene = { + -- -- `condition` is another LazyVim extension that allows you to + -- -- dynamically enable/disable linters based on the context. + -- condition = function(ctx) + -- return vim.fs.find({ "selene.toml" }, { path = ctx.filename, upward = true })[1] + -- end, + -- }, + luacheck = { + condition = function(ctx) + return vim.fs.find({ ".luacheckrc" }, { path = ctx.filename, upward = true })[1] + end, + }, }, }, config = function(_, opts) + local M = {} + local lint = require("lint") - local names = lint._resolve_linter_by_ft(vim.bo.filetype) + for name, linter in pairs(opts.linters) do + if type(linter) == "table" and type(lint.linters[name]) == "table" then + lint.linters[name] = vim.tbl_deep_extend("force", lint.linters[name], linter) + else + lint.linters[name] = linter + end + end + lint.linters_by_ft = opts.linters_by_ft + + function M.debounce(ms, fn) + local timer = vim.uv.new_timer() + return function(...) + local argv = { ... } + timer:start(ms, 0, function() + timer:stop() + vim.schedule_wrap(fn)(unpack(argv)) + end) + end + end + + function M.lint() + local names = lint._resolve_linter_by_ft(vim.bo.filetype) + + -- Create a copy of the names table to avoid modifying the original. + names = vim.list_extend({}, names) + + -- Add fallback linters. + if #names == 0 then + vim.list_extend(names, lint.linters_by_ft["_"] or {}) + end + + -- Add global linters. + vim.list_extend(names, lint.linters_by_ft["*"] or {}) + + -- Filter out linters that don't exist or don't match the condition. + local ctx = { filename = vim.api.nvim_buf_get_name(0) } + ctx.dirname = vim.fn.fnamemodify(ctx.filename, ":h") + names = vim.tbl_filter(function(name) + local linter = lint.linters[name] + if not linter then + Utils.notify("Linter not found: " .. name, "WARN", { title = "nvim-lint" }) + end + return linter and not (type(linter) == "table" and linter.condition and not linter.condition(ctx)) + end, names) + + -- Run linters. + if #names > 0 then + lint.try_lint(names) + end + end + + vim.api.nvim_create_autocmd(opts.events, { + group = Utils.augroup("nvim-lint"), + callback = M.debounce(100, M.lint), + }) end, }, } diff --git a/lua/beastvim/plugins/lsp.lua b/lua/beastvim/plugins/lsp.lua index e8beed9..6e16c1a 100644 --- a/lua/beastvim/plugins/lsp.lua +++ b/lua/beastvim/plugins/lsp.lua @@ -30,9 +30,15 @@ return { maxPreload = 100000, preloadFileSize = 10000, }, + codeLens = { + enable = true, + }, completion = { callSnippet = "Replace", }, + doc = { + privateName = { "^_" }, + }, misc = { parameters = { "--log-level=trace", @@ -76,6 +82,7 @@ return { }, diagnostics = { enabled = true }, inlay_hints = { enabled = true }, + codelens = { enabled = true }, }, config = function(_, opts) require("beastvim.features.lsp").setup(opts) @@ -88,6 +95,7 @@ return { opts = { ensure_installed = { "stylua", + "luacheck", }, ui = { icons = { diff --git a/lua/beastvim/plugins/tools.lua b/lua/beastvim/plugins/tools.lua index 55edcbe..50029ba 100644 --- a/lua/beastvim/plugins/tools.lua +++ b/lua/beastvim/plugins/tools.lua @@ -44,7 +44,7 @@ return { }, keys = { -- suggested keymap - { "p", "PasteImage", desc = "Paste clipboard image" }, + { "mp", "PasteImage", desc = "Paste clipboard image" }, }, }, @@ -54,7 +54,7 @@ return { build = "cd app && yarn install", keys = { { - "P", + "mP", function() vim.cmd([[MarkdownPreviewToggle]]) end, @@ -63,7 +63,18 @@ return { }, init = function() vim.g.mkdp_filetypes = { "markdown" } + vim.g.mkdp_theme = "light" end, ft = { "markdown" }, }, + + { + "MeanderingProgrammer/markdown.nvim", + ft = { "markdown" }, + name = "render-markdown", -- Only needed if you have another plugin named markdown.nvim + dependencies = { "nvim-treesitter/nvim-treesitter", "nvim-tree/nvim-web-devicons" }, -- if you prefer nvim-web-devicons + config = function() + require("render-markdown").setup({}) + end, + }, } diff --git a/lua/beastvim/plugins/treesitter.lua b/lua/beastvim/plugins/treesitter.lua index 80f8325..585df68 100644 --- a/lua/beastvim/plugins/treesitter.lua +++ b/lua/beastvim/plugins/treesitter.lua @@ -16,81 +16,6 @@ return { end, cmd = { "TSUpdateSync", "TSUpdate", "TSInstall" }, opts = function() - local ts_hl = require("nvim-treesitter.highlight") - - local function begin_ts_highlight(bufnr, lang, owner) - if not vim.api.nvim_buf_is_valid(bufnr) then - return - end - vim.treesitter.start(bufnr, lang) - end - - local vim_enter = true - function ts_hl.attach(bufnr, lang) - if vim_enter then - vim.treesitter.start(bufnr, lang) - vim_enter = false - return - end - local timer = vim.loop.new_timer() - vim.defer_fn(function() - local is_active = timer:is_active() - if is_active then - vim.notify("Timer haven't been closed!", vim.log.levels.ERROR) - end - end, 2000) - local has_start = false - local timout = function(opts) - local force = opts.force - local time = opts.time - if not vim.api.nvim_buf_is_valid(bufnr) then - if timer:is_active() then - timer:close() - end - return - end - if (not force) and has_start then - return - end - if timer:is_active() then - timer:close() - -- haven't start - has_start = true - begin_ts_highlight(bufnr, lang, "highligter") - end - end - vim.defer_fn(function() - timout({ force = false, time = 100 }) - end, 100) - vim.defer_fn(function() - timout({ force = true, time = 1000 }) - end, 1000) - local col = vim.fn.screencol() - local row = vim.fn.screenrow() - timer:start(5, 2, function() - vim.schedule(function() - if not vim.api.nvim_buf_is_valid(bufnr) then - if timer:is_active() then - timer:close() - end - return - end - if has_start then - return - end - local new_col = vim.fn.screencol() - local new_row = vim.fn.screenrow() - if new_row ~= row and new_col ~= col then - if timer:is_active() then - timer:close() - has_start = true - begin_ts_highlight(bufnr, lang, "highligter") - end - end - end) - end) - end - return { ensure_installed = { "vimdoc", @@ -128,7 +53,7 @@ return { enabled = true, opts = { mode = "cursor", max_lines = 3 }, keys = { - { "ut", "TSContextToggle", desc = "Toggle Treesitter Context" }, + { "tt", "TSContextToggle", desc = "Toggle Treesitter Context" }, }, }, diff --git a/lua/beastvim/plugins/ui.lua b/lua/beastvim/plugins/ui.lua index ea443cc..e1b5443 100644 --- a/lua/beastvim/plugins/ui.lua +++ b/lua/beastvim/plugins/ui.lua @@ -66,6 +66,7 @@ return { { "rebelot/heirline.nvim", event = { "BufReadPost", "BufNewFile", "BufWritePre" }, + -- lazy = true, opts = function() local monokai_opts = Utils.plugin.opts("monokai-pro.nvim") return { @@ -288,7 +289,7 @@ return { animation = { enable = true, duration = 150, fps = 60 }, autowidth = { enable = true }, }, - keys = { { "m", "WindowsMaximize", desc = "Zoom window" } }, + keys = { { "z", "WindowsMaximize", desc = "Zoom window" } }, init = function() vim.o.winwidth = 30 vim.o.winminwidth = 30 diff --git a/lua/beastvim/tweaks/init.lua b/lua/beastvim/tweaks/init.lua index a65ea8f..b93fde2 100644 --- a/lua/beastvim/tweaks/init.lua +++ b/lua/beastvim/tweaks/init.lua @@ -13,7 +13,7 @@ setmetatable(M, { end, }) ----@param mod "autocmds" | "options" | "keymaps" | "commands" +---@param mod "autocmds" | "options" | "keymaps" | "commands" | "neovide" M.load = function(mod) Utils.try(function() require("beastvim.tweaks." .. mod) @@ -49,6 +49,9 @@ function M.init() M.did_init = true M.load("options") + if vim.g.neovide then + M.load("neovide") + end end return M diff --git a/lua/beastvim/tweaks/keymaps.lua b/lua/beastvim/tweaks/keymaps.lua index 0935739..6f0babb 100644 --- a/lua/beastvim/tweaks/keymaps.lua +++ b/lua/beastvim/tweaks/keymaps.lua @@ -6,7 +6,6 @@ local map = Utils.safe_keymap_set map("n", "w", "w!", { desc = "Save" }) map("n", "q", "q!", { desc = "Quit" }) map("n", "Q", "qa!", { desc = "Quit all" }) -map("n", "", "", { desc = "Switch buffer" }) -------------------- Better window navigation ------------------ map("n", "", "h", { desc = "Go to left window", remap = true }) diff --git a/lua/beastvim/tweaks/neovide.lua b/lua/beastvim/tweaks/neovide.lua new file mode 100644 index 0000000..381a70f --- /dev/null +++ b/lua/beastvim/tweaks/neovide.lua @@ -0,0 +1,31 @@ +-- options +vim.o.linespace = 0 +vim.o.guifont = "JetBrainsMono NF:h8" + +vim.g.neovide_scale_factor = 0.8 +-- vim.g.neovide_scale_factor = 1.0 +-- vim.g.neovide_underline_stroke_scale = 1.0 +vim.g.neovide_confirm_quit = true +vim.g.neovide_fullscreen = true +vim.g.neovide_profiler = false +vim.g.neovide_cursor_nimation_length = 0.13 + +vim.g.neovide_fullscreen = false +vim.g.neovide_floating_blur_amount_x = 4.0 +vim.g.floaterm_winblend = 15 +vim.g.neovide_floating_blur_amount_y = 4.0 +vim.g.neovide_remember_window_size = true +vim.g.neovide_transparency = 1.0 +vim.g.neovide_padding_top = 0 +vim.g.neovide_padding_bottom = 0 +vim.g.neovide_padding_right = 0 +vim.g.neovide_padding_left = 0 +vim.g.neovide_cursor_trail_length = 0.2 +vim.g.neovide_cursor_vfx_mode = "railgun" -- Railgun particles behind cursor +vim.g.neovide_cursor_vfx_opacity = 200.0 +vim.g.neovide_cursor_vfx_particle_lifetime = 1.2 +vim.g.neovide_cursor_vfx_particle_density = 7.0 +vim.g.neovide_cursor_vfx_particle_speed = 10.0 +vim.g.neovide_cursor_vfx_particle_phase = 1.5 +vim.g.neovide_cursor_vfx_particle_curl = 1.0 +vim.g.neovide_cursor_unfocused_outline_width = 0.125 diff --git a/lua/beastvim/tweaks/options.lua b/lua/beastvim/tweaks/options.lua index 47a61c4..229f635 100644 --- a/lua/beastvim/tweaks/options.lua +++ b/lua/beastvim/tweaks/options.lua @@ -44,7 +44,8 @@ opt.numberwidth = 4 -- set number column width to 2 {default 4} opt.signcolumn = "yes" -- always show the sign column, otherwise it would shift the text each time opt.wrap = false -- display lines as one long line opt.sidescrolloff = 0 --- opt.smoothscroll = true +opt.scrolloff = 4 +opt.smoothscroll = true opt.laststatus = 3 opt.list = true -- Show some invisible characters (tabs... opt.guicursor = "n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20" @@ -55,7 +56,6 @@ opt.virtualedit = "onemore" opt.showcmd = false opt.title = true opt.titlestring = "%<%F%=%l/%L - nvim" -opt.linespace = 8 opt.mousemoveevent = true opt.syntax = "off" opt.spelllang = { "en", "vi" }