From fb4b15a8ef5be6379ab608e57f8cf8e968e69428 Mon Sep 17 00:00:00 2001 From: Greg Date: Mon, 31 Mar 2025 18:02:24 +0300 Subject: [PATCH] nvim --- .config/nvim/init.lua | 208 ++++++++++++++---------------------- .config/nvim/lazy-lock.json | 59 +++++----- 2 files changed, 112 insertions(+), 155 deletions(-) diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index a8aad71..35bd032 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -297,6 +297,7 @@ require("lazy").setup({ { "fredrikaverpil/neotest-golang", version = "*" }, -- Installation }, config = function() + ---@diagnostic disable-next-line: missing-fields require("neotest").setup { adapters = { require "neotest-golang", -- Registration @@ -363,7 +364,6 @@ require("lazy").setup({ { "folke/flash.nvim", event = "VeryLazy", - ---@type Flash.Config opts = { jump = { autojump = true, @@ -564,6 +564,7 @@ require("lazy").setup({ { -- Main LSP Configuration "neovim/nvim-lspconfig", + lazy = false, dependencies = { -- Automatically install LSPs and related tools to stdpath for Neovim { "williamboman/mason.nvim", config = true }, -- NOTE: Must be loaded before dependants @@ -574,9 +575,23 @@ require("lazy").setup({ -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` { "j-hui/fidget.nvim", opts = {} }, - -- Allows extra capabilities provided by nvim-cmp - "hrsh7th/cmp-nvim-lsp", + -- autocompletion + -- main one + { "ms-jpq/coq_nvim", branch = "coq" }, + + -- 9000+ Snippets + { "ms-jpq/coq.artifacts", branch = "artifacts" }, + + -- lua & third party sources -- See https://github.com/ms-jpq/coq.thirdparty + -- Need to **configure separately** + { "ms-jpq/coq.thirdparty", branch = "3p" }, }, + init = function() + vim.g.coq_settings = { + auto_start = true, -- if you want to start COQ at startup + -- Your COQ settings here + } + end, config = function() -- Brief aside: **What is LSP?** -- @@ -649,6 +664,11 @@ require("lazy").setup({ -- Most Language Servers support renaming across files, etc. map("rn", vim.lsp.buf.rename, "[R]e[n]ame") + -- Move file to a new place. + map("mv", function() + vim.cmd "TSToolsRenameFile" + end, "[M]o[v]e") + -- Execute a code action, usually your cursor needs to be on top of an error -- or a suggestion from your LSP for this to activate. map("ca", vim.lsp.buf.code_action, "[C]ode [A]ction", { "n", "x" }) @@ -692,8 +712,8 @@ require("lazy").setup({ -- By default, Neovim doesn't support everything that is in the LSP specification. -- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities. -- So, we create new capabilities with nvim cmp, and then broadcast that to the servers. - local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities = vim.tbl_deep_extend("force", capabilities, require("cmp_nvim_lsp").default_capabilities()) + -- local capabilities = vim.lsp.protocol.make_client_capabilities() + -- capabilities = vim.tbl_deep_extend("force", capabilities, require("cmp_nvim_lsp").default_capabilities()) -- Enable the following language servers -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. @@ -767,26 +787,72 @@ require("lazy").setup({ -- You can add other tools here that you want Mason to install -- for you, so that they are available from within Neovim. local ensure_installed = vim.tbl_keys(servers or {}) - vim.list_extend(ensure_installed, { - "stylua", -- Used to format Lua code - }) + ensure_installed = table.insert(ensure_installed, "stylua") require("mason-tool-installer").setup { ensure_installed = ensure_installed } require("mason-lspconfig").setup { + ensure_installed = ensure_installed, + automatic_installation = true, handlers = { function(server_name) local server = servers[server_name] or {} -- This handles overriding only values explicitly passed -- by the server configuration above. Useful when disabling -- certain features of an LSP (for example, turning off formatting for ts_ls) - server.capabilities = vim.tbl_deep_extend("force", {}, capabilities, server.capabilities or {}) + server.capabilities = vim.tbl_deep_extend("force", {}, server.capabilities or {}) require("lspconfig")[server_name].setup(server) end, }, } end, }, - + { + "pmizio/typescript-tools.nvim", + dependencies = { "nvim-lua/plenary.nvim", "neovim/nvim-lspconfig" }, + opts = { + -- spawn additional tsserver instance to calculate diagnostics on it + separate_diagnostic_server = true, + -- "change"|"insert_leave" determine when the client asks the server about diagnostic + publish_diagnostic_on = "insert_leave", + -- array of strings("fix_all"|"add_missing_imports"|"remove_unused"| + -- "remove_unused_imports"|"organize_imports") -- or string "all" + -- to include all supported code actions + -- specify commands exposed as code_actions + expose_as_code_action = "all", + -- string|nil - specify a custom path to `tsserver.js` file, if this is nil or file under path + -- not exists then standard path resolution strategy is applied + tsserver_path = nil, + -- specify a list of plugins to load by tsserver, e.g., for support `styled-components` + -- (see 💅 `styled-components` support section) + tsserver_plugins = {}, + -- this value is passed to: https://nodejs.org/api/cli.html#--max-old-space-sizesize-in-megabytes + -- memory limit in megabytes or "auto"(basically no limit) + tsserver_max_memory = "auto", + -- described below + tsserver_format_options = {}, + tsserver_file_preferences = {}, + -- locale of all tsserver messages, supported locales you can find here: + -- https://github.com/microsoft/TypeScript/blob/3c221fc086be52b19801f6e8d82596d04607ede6/src/compiler/utilitiesPublic.ts#L620 + tsserver_locale = "en", + -- mirror of VSCode's `typescript.suggest.completeFunctionCalls` + complete_function_calls = false, + include_completions_with_insert_text = true, + -- CodeLens + -- WARNING: Experimental feature also in VSCode, because it might hit performance of server. + -- possible values: ("off"|"all"|"implementations_only"|"references_only") + code_lens = "off", + -- by default code lenses are displayed on all referencable values and for some of you it can + -- be too much this option reduce count of them by removing member references from lenses + disable_member_code_lens = true, + -- JSXCloseTag + -- WARNING: it is disabled by default (maybe you configuration or distro already uses nvim-ts-autotag, + -- that maybe have a conflict if enable this feature. ) + jsx_close_tag = { + enable = true, + filetypes = { "javascriptreact", "typescriptreact" }, + }, + }, + }, { -- Autoformat "stevearc/conform.nvim", event = { "BufWritePre" }, @@ -811,8 +877,8 @@ require("lazy").setup({ local lsp_format_opt if disable_filetypes[vim.bo[bufnr].filetype] then lsp_format_opt = "never" - else - lsp_format_opt = "fallback" + --else + -- lsp_format_opt = "fallback" end return { timeout_ms = 500, @@ -821,6 +887,10 @@ require("lazy").setup({ end, formatters_by_ft = { lua = { "stylua" }, + javascript = { "biome", "biome-organize-imports" }, + javascriptreact = { "biome", "biome-organize-imports" }, + typescript = { "biome", "biome-organize-imports" }, + typescriptreact = { "biome", "biome-organize-imports" }, -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- @@ -829,119 +899,6 @@ require("lazy").setup({ }, }, }, - - { -- Autocompletion - "hrsh7th/nvim-cmp", - event = "InsertEnter", - dependencies = { - -- Snippet Engine & its associated nvim-cmp source - { - "L3MON4D3/LuaSnip", - build = (function() - -- Build Step is needed for regex support in snippets. - -- This step is not supported in many windows environments. - -- Remove the below condition to re-enable on windows. - if vim.fn.has "win32" == 1 or vim.fn.executable "make" == 0 then - return - end - return "make install_jsregexp" - end)(), - dependencies = { - -- `friendly-snippets` contains a variety of premade snippets. - -- See the README about individual language/framework/plugin snippets: - -- https://github.com/rafamadriz/friendly-snippets - { - "rafamadriz/friendly-snippets", - config = function() - require("luasnip.loaders.from_vscode").lazy_load() - end, - }, - }, - }, - "saadparwaiz1/cmp_luasnip", - - -- Adds other completion capabilities. - -- nvim-cmp does not ship with all sources by default. They are split - -- into multiple repos for maintenance purposes. - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-path", - }, - config = function() - -- See `:help cmp` - local cmp = require "cmp" - local luasnip = require "luasnip" - luasnip.config.setup {} - - cmp.setup { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - completion = { completeopt = "menu,menuone,noinsert" }, - - -- For an understanding of why these mappings were - -- chosen, you will need to read `:help ins-completion` - -- - -- No, but seriously. Please read `:help ins-completion`, it is really good! - mapping = cmp.mapping.preset.insert { - -- Select the [n]ext item - [""] = cmp.mapping.select_next_item(), - -- Select the [p]revious item - [""] = cmp.mapping.select_prev_item(), - - -- Scroll the documentation window [b]ack / [f]orward - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - - -- Accept ([y]es) the completion. - -- This will auto-import if your LSP supports it. - -- This will expand snippets if the LSP sent a snippet. - [""] = cmp.mapping.confirm { select = true }, - - -- If you prefer more traditional completion keymaps, - -- you can uncomment the following lines - [""] = cmp.mapping.confirm { select = true }, - [""] = cmp.mapping.select_next_item(), - [""] = cmp.mapping.select_prev_item(), - -- Manually trigger a completion from nvim-cmp. - -- Generally you don't need this, because nvim-cmp will display - -- completions whenever it has completion options available. - [""] = cmp.mapping.complete {}, - -- Think of as moving to the right of your snippet expansion. - -- So if you have a snippet that's like: - -- function $name($args) - -- $body - -- end - -- will move you to the right of each of the expansion locations. - -- is similar, except moving you backwards. - [""] = cmp.mapping(function() - if luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - end - end, { "i", "s" }), - [""] = cmp.mapping(function() - if luasnip.locally_jumpable(-1) then - end - end, { "i", "s" }), - - -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: - -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps - }, - sources = { - { - name = "lazydev", - -- set group index to 0 to skip loading LuaLS completions as lazydev recommends it - group_index = 0, - }, - { name = "nvim_lsp" }, - { name = "luasnip" }, - { name = "path" }, - }, - } - end, - }, - { -- You can easily change to a different colorscheme. -- Change the name of the colorscheme plugin below, and then -- change the command in the config to whatever the name of that colorscheme is. @@ -1077,6 +1034,7 @@ require("lazy").setup({ -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` -- { import = 'custom.plugins' }, + ---@diagnostic disable-next-line: missing-fields }, { -- colorscheme that will be used when installing plugins. install = { colorscheme = { "tokyonight-storm" } }, diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 2dd906a..7d13f8b 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,36 +1,35 @@ { "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, - "LuaSnip": { "branch": "master", "commit": "2737edc9e674e537dc0a97e3405658d57d2d31ed" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, - "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, - "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, - "conform.nvim": { "branch": "master", "commit": "e3263eabbfc1bdbc5b6a60ba8431b64e8dca0a79" }, - "dressing.nvim": { "branch": "master", "commit": "6ef1ca479d37d4ff66f13eed44d08912caff483a" }, - "fidget.nvim": { "branch": "main", "commit": "e2a175c2abe2d4f65357da1c98c59a5cfb2b543f" }, - "flash.nvim": { "branch": "main", "commit": "34c7be146a91fec3555c33fe89c7d643f6ef5cf1" }, - "friendly-snippets": { "branch": "main", "commit": "de8fce94985873666bd9712ea3e49ee17aadb1ed" }, - "lazy.nvim": { "branch": "main", "commit": "60cf258a9ae7fffe04bb31141141a91845158dcc" }, - "lazydev.nvim": { "branch": "main", "commit": "d5800897d9180cea800023f2429bce0a94ed6064" }, - "luvit-meta": { "branch": "main", "commit": "ce76f6f6cdc9201523a5875a4471dcfe0186eb60" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "4d0e5b49363cac187326998b96aa6a2884e0e89b" }, - "mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" }, - "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, - "mini.nvim": { "branch": "main", "commit": "998cfcf1fdd0a6830d0fc35f1c054a6f55de1e7f" }, - "neotest": { "branch": "master", "commit": "6d3d22cdad49999ef774ebe1bc250a4994038964" }, - "neotest-golang": { "branch": "main", "commit": "df6e3f34ae65f2520db798481a9d3f97581899b7" }, - "nvim-autopairs": { "branch": "master", "commit": "ee297f215e95a60b01fde33275cc3c820eddeebe" }, - "nvim-cmp": { "branch": "main", "commit": "f17d9b4394027ff4442b298398dfcaab97e40c4f" }, - "nvim-lspconfig": { "branch": "master", "commit": "d01864641c6e43c681c3e9f6cf4745c75fdd9dcc" }, - "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, - "nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" }, - "nvim-treesitter": { "branch": "master", "commit": "8e40904e49bbad5812798eb54be8c00d77cdd301" }, - "nvim-web-devicons": { "branch": "master", "commit": "19d257cf889f79f4022163c3fbb5e08639077bd8" }, - "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, - "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" }, + "auto-save.nvim": { "branch": "main", "commit": "24af023800c48645e6472cb6f30cebe782288446" }, + "conform.nvim": { "branch": "master", "commit": "b1a75324ddf96b7bb84963a297b1ed334db087c0" }, + "coq.artifacts": { "branch": "artifacts", "commit": "ef5f21d638ccc456cfa5b8d0ab37093cefe48c8b" }, + "coq.thirdparty": { "branch": "3p", "commit": "6ee3c221c308dca7071387267ac76c9272b184a9" }, + "coq_nvim": { "branch": "coq", "commit": "d83bc18d044cfcd65e91dc49740a353546bc143b" }, + "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, + "fidget.nvim": { "branch": "main", "commit": "d9ba6b7bfe29b3119a610892af67602641da778e" }, + "flash.nvim": { "branch": "main", "commit": "3c942666f115e2811e959eabbdd361a025db8b63" }, + "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, + "lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" }, + "luvit-meta": { "branch": "main", "commit": "1df30b60b1b4aecfebc785aa98943db6c6989716" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "1a31f824b9cd5bc6f342fc29e9a53b60d74af245" }, + "mason-tool-installer.nvim": { "branch": "main", "commit": "98767d37f8e5255a5111fc1e3163232d4dc07bda" }, + "mason.nvim": { "branch": "main", "commit": "fc98833b6da5de5a9c5b1446ac541577059555be" }, + "mini.nvim": { "branch": "main", "commit": "d0464ced00abfd9bbed196fa36ccf3b1691c6b2c" }, + "neotest": { "branch": "master", "commit": "dddbe8fe358b05b2b7e54fe4faab50563171a76d" }, + "neotest-golang": { "branch": "main", "commit": "131e0402e63966692d340861c58756853913ada3" }, + "nvim-autopairs": { "branch": "master", "commit": "6522027785b305269fa17088395dfc0f456cedd2" }, + "nvim-lspconfig": { "branch": "master", "commit": "ff6471d4f837354d8257dfa326b031dd8858b16e" }, + "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, + "nvim-surround": { "branch": "main", "commit": "caf6f633d4d77a29b6e265b560c5a035d171a913" }, + "nvim-treesitter": { "branch": "master", "commit": "9be6836ebeb88a536055bf1ce0961eef68da4bc6" }, + "nvim-web-devicons": { "branch": "master", "commit": "4c3a5848ee0b09ecdea73adcd2a689190aeb728c" }, + "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, - "todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" }, - "tokyonight.nvim": { "branch": "main", "commit": "ce91ba480070c95f40753e4663e32b4632ac6db3" }, + "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, + "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }, + "typescript-tools.nvim": { "branch": "master", "commit": "e0887c1e336edbb01243e9f1e60d74b0bc0a2bed" }, "vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }, - "which-key.nvim": { "branch": "main", "commit": "68e37e12913a66b60073906f5d3f14dee0de19f2" } + "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } }