Skip to content

Commit c3c0b45

Browse files
authored
finally no double autocomplete (#7)
1 parent 2fa0eab commit c3c0b45

File tree

5 files changed

+122
-108
lines changed

5 files changed

+122
-108
lines changed

init.lua

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,8 @@ require('lazy').setup({
316316
require 'kickstart.plugins.lsp',
317317
{ -- Autoformat
318318
'stevearc/conform.nvim',
319-
lazy = false,
319+
event = { 'BufWritePre' },
320+
cmd = { 'ConformInfo' },
320321
keys = {
321322
{
322323
'<leader>f',
@@ -334,10 +335,14 @@ require('lazy').setup({
334335
-- have a well standardized coding style. You can add additional
335336
-- languages here or re-enable it for the disabled ones.
336337
local disable_filetypes = { c = true, cpp = true }
337-
return {
338-
timeout_ms = 500,
339-
lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype],
340-
}
338+
if disable_filetypes[vim.bo[bufnr].filetype] then
339+
return nil
340+
else
341+
return {
342+
timeout_ms = 500,
343+
lsp_format = 'fallback',
344+
}
345+
end
341346
end,
342347
formatters_by_ft = {
343348
lua = { 'stylua' },
@@ -368,7 +373,10 @@ require('lazy').setup({
368373
},
369374
},
370375

371-
require 'kickstart.plugins.autocomplete',
376+
-- autocomplete/autocompletion engines
377+
-- require 'kickstart.plugins.autocomplete.blink-cmp',
378+
require 'kickstart.plugins.autocomplete.nvim-cmp',
379+
372380
-- THEMES
373381
-- require 'kickstart.plugins.themes.tokyonight',
374382
require 'kickstart.plugins.themes.catppuccin',
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
return { -- Autocompletion
2+
'saghen/blink.cmp',
3+
event = 'VimEnter',
4+
version = '1.*',
5+
dependencies = {
6+
-- Snippet Engine
7+
{
8+
'L3MON4D3/LuaSnip',
9+
version = '2.*',
10+
build = (function()
11+
-- Build Step is needed for regex support in snippets.
12+
-- This step is not supported in many windows environments.
13+
-- Remove the below condition to re-enable on windows.
14+
if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then
15+
return
16+
end
17+
return 'make install_jsregexp'
18+
end)(),
19+
dependencies = {
20+
-- `friendly-snippets` contains a variety of premade snippets.
21+
-- See the README about individual language/framework/plugin snippets:
22+
-- https://github.com/rafamadriz/friendly-snippets
23+
-- {
24+
-- 'rafamadriz/friendly-snippets',
25+
-- config = function()
26+
-- require('luasnip.loaders.from_vscode').lazy_load()
27+
-- end,
28+
-- },
29+
},
30+
opts = {},
31+
},
32+
'folke/lazydev.nvim',
33+
},
34+
--- @module 'blink.cmp'
35+
--- @type blink.cmp.Config
36+
opts = {
37+
keymap = {
38+
-- 'default' (recommended) for mappings similar to built-in completions
39+
-- <c-y> to accept ([y]es) the completion.
40+
-- This will auto-import if your LSP supports it.
41+
-- This will expand snippets if the LSP sent a snippet.
42+
-- 'super-tab' for tab to accept
43+
-- 'enter' for enter to accept
44+
-- 'none' for no mappings
45+
--
46+
-- For an understanding of why the 'default' preset is recommended,
47+
-- you will need to read `:help ins-completion`
48+
--
49+
-- No, but seriously. Please read `:help ins-completion`, it is really good!
50+
--
51+
-- All presets have the following mappings:
52+
-- <tab>/<s-tab>: move to right/left of your snippet expansion
53+
-- <c-space>: Open menu or open docs if already open
54+
-- <c-n>/<c-p> or <up>/<down>: Select next/previous item
55+
-- <c-e>: Hide menu
56+
-- <c-k>: Toggle signature help
57+
--
58+
-- See :h blink-cmp-config-keymap for defining your own keymap
59+
preset = 'default',
60+
61+
-- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
62+
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
63+
},
64+
65+
appearance = {
66+
-- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
67+
-- Adjusts spacing to ensure icons are aligned
68+
nerd_font_variant = 'mono',
69+
},
70+
71+
completion = {
72+
-- By default, you may press `<c-space>` to show the documentation.
73+
-- Optionally, set `auto_show = true` to show the documentation after a delay.
74+
documentation = { auto_show = false, auto_show_delay_ms = 500 },
75+
},
76+
77+
sources = {
78+
default = { 'lsp', 'path', 'snippets', 'lazydev' },
79+
providers = {
80+
lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 },
81+
},
82+
},
83+
84+
snippets = { preset = 'luasnip' },
85+
86+
-- Blink.cmp includes an optional, recommended rust fuzzy matcher,
87+
-- which automatically downloads a prebuilt binary when enabled.
88+
--
89+
-- By default, we use the Lua implementation instead, but you may enable
90+
-- the rust implementation via `'prefer_rust_with_warning'`
91+
--
92+
-- See :h blink-cmp-config-fuzzy for more information
93+
fuzzy = { implementation = 'lua' },
94+
95+
-- Shows a signature help window while you type arguments for a function
96+
signature = { enabled = true },
97+
},
98+
}

lua/kickstart/plugins/autocomplete.lua renamed to lua/kickstart/plugins/autocomplete/nvim-cmp.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,3 @@ return { -- Autocompletion
108108
}
109109
end,
110110
}
111-

lua/kickstart/plugins/lsp.lua

Lines changed: 2 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ return {
162162
--
163163
-- This may be unwanted, since they displace some of your code
164164
vim.lsp.inlay_hint.enable(true)
165-
if client and client.server_capabilities.inlayHintProvider then
165+
if client and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_inlayHint, event.buf) then
166166
map('<leader>th', function()
167-
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
167+
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf })
168168
end, '[T]oggle Inlay [H]ints')
169169
end
170170
end,
@@ -267,103 +267,4 @@ return {
267267
require('lsp_signature').setup(opts)
268268
end,
269269
},
270-
271-
{ -- Autocompletion
272-
'saghen/blink.cmp',
273-
event = 'VimEnter',
274-
version = '1.*',
275-
dependencies = {
276-
-- Snippet Engine
277-
{
278-
'L3MON4D3/LuaSnip',
279-
version = '2.*',
280-
build = (function()
281-
-- Build Step is needed for regex support in snippets.
282-
-- This step is not supported in many windows environments.
283-
-- Remove the below condition to re-enable on windows.
284-
if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then
285-
return
286-
end
287-
return 'make install_jsregexp'
288-
end)(),
289-
dependencies = {
290-
-- `friendly-snippets` contains a variety of premade snippets.
291-
-- See the README about individual language/framework/plugin snippets:
292-
-- https://github.com/rafamadriz/friendly-snippets
293-
-- {
294-
-- 'rafamadriz/friendly-snippets',
295-
-- config = function()
296-
-- require('luasnip.loaders.from_vscode').lazy_load()
297-
-- end,
298-
-- },
299-
},
300-
opts = {},
301-
},
302-
'folke/lazydev.nvim',
303-
},
304-
--- @module 'blink.cmp'
305-
--- @type blink.cmp.Config
306-
opts = {
307-
keymap = {
308-
-- 'default' (recommended) for mappings similar to built-in completions
309-
-- <c-y> to accept ([y]es) the completion.
310-
-- This will auto-import if your LSP supports it.
311-
-- This will expand snippets if the LSP sent a snippet.
312-
-- 'super-tab' for tab to accept
313-
-- 'enter' for enter to accept
314-
-- 'none' for no mappings
315-
--
316-
-- For an understanding of why the 'default' preset is recommended,
317-
-- you will need to read `:help ins-completion`
318-
--
319-
-- No, but seriously. Please read `:help ins-completion`, it is really good!
320-
--
321-
-- All presets have the following mappings:
322-
-- <tab>/<s-tab>: move to right/left of your snippet expansion
323-
-- <c-space>: Open menu or open docs if already open
324-
-- <c-n>/<c-p> or <up>/<down>: Select next/previous item
325-
-- <c-e>: Hide menu
326-
-- <c-k>: Toggle signature help
327-
--
328-
-- See :h blink-cmp-config-keymap for defining your own keymap
329-
preset = 'default',
330-
331-
-- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
332-
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
333-
},
334-
335-
appearance = {
336-
-- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
337-
-- Adjusts spacing to ensure icons are aligned
338-
nerd_font_variant = 'mono',
339-
},
340-
341-
completion = {
342-
-- By default, you may press `<c-space>` to show the documentation.
343-
-- Optionally, set `auto_show = true` to show the documentation after a delay.
344-
documentation = { auto_show = false, auto_show_delay_ms = 500 },
345-
},
346-
347-
sources = {
348-
default = { 'lsp', 'path', 'snippets', 'lazydev' },
349-
providers = {
350-
lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 },
351-
},
352-
},
353-
354-
snippets = { preset = 'luasnip' },
355-
356-
-- Blink.cmp includes an optional, recommended rust fuzzy matcher,
357-
-- which automatically downloads a prebuilt binary when enabled.
358-
--
359-
-- By default, we use the Lua implementation instead, but you may enable
360-
-- the rust implementation via `'prefer_rust_with_warning'`
361-
--
362-
-- See :h blink-cmp-config-fuzzy for more information
363-
fuzzy = { implementation = 'lua' },
364-
365-
-- Shows a signature help window while you type arguments for a function
366-
signature = { enabled = true },
367-
},
368-
},
369270
}

lua/utils/languages.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ local Languages = {
2323
disableLanguageServices = false,
2424
},
2525
basedpyright = {
26+
capabilities = {
27+
-- Basedpyright does not support these capabilities well.
28+
definitionProvider = false,
29+
typeDefinitionProvider = false,
30+
implementationProvider = false,
31+
referencesProvider = false,
32+
-- hoverProvider = false, -- decide if pyright or basedpyright
33+
},
2634
settings = {
2735
basedpyright = {
2836
analysis = {

0 commit comments

Comments
 (0)