From c3c0b45e6e6b03dfa045e5483aa78223f9713bb1 Mon Sep 17 00:00:00 2001 From: peturparkur <61064454+peturparkur@users.noreply.github.com> Date: Sun, 17 Aug 2025 21:20:47 +0200 Subject: [PATCH] finally no double autocomplete (#7) --- init.lua | 20 +++- .../plugins/autocomplete/blink-cmp.lua | 98 +++++++++++++++++ .../nvim-cmp.lua} | 1 - lua/kickstart/plugins/lsp.lua | 103 +----------------- lua/utils/languages.lua | 8 ++ 5 files changed, 122 insertions(+), 108 deletions(-) create mode 100644 lua/kickstart/plugins/autocomplete/blink-cmp.lua rename lua/kickstart/plugins/{autocomplete.lua => autocomplete/nvim-cmp.lua} (99%) diff --git a/init.lua b/init.lua index 8557b3ce..daf85fe3 100644 --- a/init.lua +++ b/init.lua @@ -316,7 +316,8 @@ require('lazy').setup({ require 'kickstart.plugins.lsp', { -- Autoformat 'stevearc/conform.nvim', - lazy = false, + event = { 'BufWritePre' }, + cmd = { 'ConformInfo' }, keys = { { 'f', @@ -334,10 +335,14 @@ require('lazy').setup({ -- have a well standardized coding style. You can add additional -- languages here or re-enable it for the disabled ones. local disable_filetypes = { c = true, cpp = true } - return { - timeout_ms = 500, - lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype], - } + if disable_filetypes[vim.bo[bufnr].filetype] then + return nil + else + return { + timeout_ms = 500, + lsp_format = 'fallback', + } + end end, formatters_by_ft = { lua = { 'stylua' }, @@ -368,7 +373,10 @@ require('lazy').setup({ }, }, - require 'kickstart.plugins.autocomplete', + -- autocomplete/autocompletion engines + -- require 'kickstart.plugins.autocomplete.blink-cmp', + require 'kickstart.plugins.autocomplete.nvim-cmp', + -- THEMES -- require 'kickstart.plugins.themes.tokyonight', require 'kickstart.plugins.themes.catppuccin', diff --git a/lua/kickstart/plugins/autocomplete/blink-cmp.lua b/lua/kickstart/plugins/autocomplete/blink-cmp.lua new file mode 100644 index 00000000..fbbac008 --- /dev/null +++ b/lua/kickstart/plugins/autocomplete/blink-cmp.lua @@ -0,0 +1,98 @@ +return { -- Autocompletion + 'saghen/blink.cmp', + event = 'VimEnter', + version = '1.*', + dependencies = { + -- Snippet Engine + { + 'L3MON4D3/LuaSnip', + version = '2.*', + 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, + -- }, + }, + opts = {}, + }, + 'folke/lazydev.nvim', + }, + --- @module 'blink.cmp' + --- @type blink.cmp.Config + opts = { + keymap = { + -- 'default' (recommended) for mappings similar to built-in completions + -- to accept ([y]es) the completion. + -- This will auto-import if your LSP supports it. + -- This will expand snippets if the LSP sent a snippet. + -- 'super-tab' for tab to accept + -- 'enter' for enter to accept + -- 'none' for no mappings + -- + -- For an understanding of why the 'default' preset is recommended, + -- you will need to read `:help ins-completion` + -- + -- No, but seriously. Please read `:help ins-completion`, it is really good! + -- + -- All presets have the following mappings: + -- /: move to right/left of your snippet expansion + -- : Open menu or open docs if already open + -- / or /: Select next/previous item + -- : Hide menu + -- : Toggle signature help + -- + -- See :h blink-cmp-config-keymap for defining your own keymap + preset = 'default', + + -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: + -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps + }, + + appearance = { + -- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font' + -- Adjusts spacing to ensure icons are aligned + nerd_font_variant = 'mono', + }, + + completion = { + -- By default, you may press `` to show the documentation. + -- Optionally, set `auto_show = true` to show the documentation after a delay. + documentation = { auto_show = false, auto_show_delay_ms = 500 }, + }, + + sources = { + default = { 'lsp', 'path', 'snippets', 'lazydev' }, + providers = { + lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 }, + }, + }, + + snippets = { preset = 'luasnip' }, + + -- Blink.cmp includes an optional, recommended rust fuzzy matcher, + -- which automatically downloads a prebuilt binary when enabled. + -- + -- By default, we use the Lua implementation instead, but you may enable + -- the rust implementation via `'prefer_rust_with_warning'` + -- + -- See :h blink-cmp-config-fuzzy for more information + fuzzy = { implementation = 'lua' }, + + -- Shows a signature help window while you type arguments for a function + signature = { enabled = true }, + }, +} diff --git a/lua/kickstart/plugins/autocomplete.lua b/lua/kickstart/plugins/autocomplete/nvim-cmp.lua similarity index 99% rename from lua/kickstart/plugins/autocomplete.lua rename to lua/kickstart/plugins/autocomplete/nvim-cmp.lua index 53026f6f..71e6c6dd 100644 --- a/lua/kickstart/plugins/autocomplete.lua +++ b/lua/kickstart/plugins/autocomplete/nvim-cmp.lua @@ -108,4 +108,3 @@ return { -- Autocompletion } end, } - diff --git a/lua/kickstart/plugins/lsp.lua b/lua/kickstart/plugins/lsp.lua index 0a653249..2a9bfab3 100644 --- a/lua/kickstart/plugins/lsp.lua +++ b/lua/kickstart/plugins/lsp.lua @@ -162,9 +162,9 @@ return { -- -- This may be unwanted, since they displace some of your code vim.lsp.inlay_hint.enable(true) - if client and client.server_capabilities.inlayHintProvider then + if client and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_inlayHint, event.buf) then map('th', function() - vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) + vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) end, '[T]oggle Inlay [H]ints') end end, @@ -267,103 +267,4 @@ return { require('lsp_signature').setup(opts) end, }, - - { -- Autocompletion - 'saghen/blink.cmp', - event = 'VimEnter', - version = '1.*', - dependencies = { - -- Snippet Engine - { - 'L3MON4D3/LuaSnip', - version = '2.*', - 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, - -- }, - }, - opts = {}, - }, - 'folke/lazydev.nvim', - }, - --- @module 'blink.cmp' - --- @type blink.cmp.Config - opts = { - keymap = { - -- 'default' (recommended) for mappings similar to built-in completions - -- to accept ([y]es) the completion. - -- This will auto-import if your LSP supports it. - -- This will expand snippets if the LSP sent a snippet. - -- 'super-tab' for tab to accept - -- 'enter' for enter to accept - -- 'none' for no mappings - -- - -- For an understanding of why the 'default' preset is recommended, - -- you will need to read `:help ins-completion` - -- - -- No, but seriously. Please read `:help ins-completion`, it is really good! - -- - -- All presets have the following mappings: - -- /: move to right/left of your snippet expansion - -- : Open menu or open docs if already open - -- / or /: Select next/previous item - -- : Hide menu - -- : Toggle signature help - -- - -- See :h blink-cmp-config-keymap for defining your own keymap - preset = 'default', - - -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: - -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps - }, - - appearance = { - -- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font' - -- Adjusts spacing to ensure icons are aligned - nerd_font_variant = 'mono', - }, - - completion = { - -- By default, you may press `` to show the documentation. - -- Optionally, set `auto_show = true` to show the documentation after a delay. - documentation = { auto_show = false, auto_show_delay_ms = 500 }, - }, - - sources = { - default = { 'lsp', 'path', 'snippets', 'lazydev' }, - providers = { - lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 }, - }, - }, - - snippets = { preset = 'luasnip' }, - - -- Blink.cmp includes an optional, recommended rust fuzzy matcher, - -- which automatically downloads a prebuilt binary when enabled. - -- - -- By default, we use the Lua implementation instead, but you may enable - -- the rust implementation via `'prefer_rust_with_warning'` - -- - -- See :h blink-cmp-config-fuzzy for more information - fuzzy = { implementation = 'lua' }, - - -- Shows a signature help window while you type arguments for a function - signature = { enabled = true }, - }, - }, } diff --git a/lua/utils/languages.lua b/lua/utils/languages.lua index 2ba4e0f3..341d64f9 100644 --- a/lua/utils/languages.lua +++ b/lua/utils/languages.lua @@ -23,6 +23,14 @@ local Languages = { disableLanguageServices = false, }, basedpyright = { + capabilities = { + -- Basedpyright does not support these capabilities well. + definitionProvider = false, + typeDefinitionProvider = false, + implementationProvider = false, + referencesProvider = false, + -- hoverProvider = false, -- decide if pyright or basedpyright + }, settings = { basedpyright = { analysis = {