Use blink.cmp & tsgo

This commit is contained in:
Jan Hamal Dvořák 2026-02-15 13:52:25 +01:00
parent 295c49979e
commit 2f4166f9ef
4 changed files with 60 additions and 13 deletions

3
.gitmodules vendored
View file

@ -25,3 +25,6 @@
[submodule "bundle/conform"] [submodule "bundle/conform"]
path = bundle/conform path = bundle/conform
url = https://github.com/stevearc/conform.nvim.git url = https://github.com/stevearc/conform.nvim.git
[submodule "bundle/blink.cmp"]
path = bundle/blink.cmp
url = https://github.com/saghen/blink.cmp.git

1
bundle/blink.cmp Submodule

@ -0,0 +1 @@
Subproject commit cd79f572971c58784ca72551af29af3a63da9168

View file

@ -28,7 +28,7 @@ autocmd FileType c,cpp set cinoptions=:0,l0,t0,g0,(0
autocmd FileType c setlocal ts=8 sw=8 noet autocmd FileType c setlocal ts=8 sw=8 noet
autocmd FileType python setlocal ts=4 sw=4 et autocmd FileType python setlocal ts=4 sw=4 et
autocmd FileType asciidoctor setlocal wrap lbr iskeyword+=- autocmd FileType asciidoctor setlocal wrap lbr iskeyword+=-
autocmd FileType vue,javascript,typescript set completeopt=menu,menuone,noinsert,fuzzy "autocmd FileType vue,javascript,typescript set completeopt=menu,menuone,noinsert,fuzzy
autocmd FileType lua setlocal ts=2 sw=2 et autocmd FileType lua setlocal ts=2 sw=2 et
autocmd BufNewFile,BufRead *.pio setfiletype pioasm autocmd BufNewFile,BufRead *.pio setfiletype pioasm

View file

@ -139,9 +139,9 @@ vim.lsp.config("vtsls", {
}, },
}, },
filetypes = { filetypes = {
"javascript", -- "javascript",
"javascriptreact", "javascriptreact",
"typescript", -- "typescript",
"typescriptreact", "typescriptreact",
"vue", "vue",
} }
@ -156,6 +156,19 @@ vim.lsp.config("vue_ls", {
} }
}) })
vim.lsp.enable("golar")
vim.lsp.config("golar", {
settings = {
},
filetypes = {
"javascript",
-- "javascriptreact",
"typescript",
-- "typescriptreact",
-- "vue",
}
})
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd("FileType", {
pattern = "vue", pattern = "vue",
callback = function() callback = function()
@ -193,17 +206,47 @@ vim.lsp.config("rust_analyzer", {})
-- end, -- end,
-- }) -- })
local function check_back_space() -- local function check_back_space()
local col = vim.fn.col('.') - 1 -- local col = vim.fn.col('.') - 1
return col <= 0 or vim.fn.getline('.'):sub(col, col):match('%s') -- return col <= 0 or vim.fn.getline('.'):sub(col, col):match('%s')
end -- end
--
-- function tab_complete()
-- if check_back_space() then
-- return vim.api.nvim_replace_termcodes('<Tab>', true, false, true)
-- end
-- return vim.api.nvim_replace_termcodes('<C-p>', true, false, true)
-- end
--
-- vim.api.nvim_set_keymap('i', '<Tab>', 'v:lua.tab_complete()', { expr = true, noremap = true })
-- vim.api.nvim_set_keymap('i', '<S-Tab>', '<C-n>', { noremap = true })
function tab_complete() local has_words_before = function()
if check_back_space() then local col = vim.api.nvim_win_get_cursor(0)[2]
return vim.api.nvim_replace_termcodes('<Tab>', true, false, true) if col == 0 then
return false
end end
return vim.api.nvim_replace_termcodes('<C-p>', true, false, true) local line = vim.api.nvim_get_current_line()
return line:sub(col, col):match("%s") == nil
end end
vim.api.nvim_set_keymap('i', '<Tab>', 'v:lua.tab_complete()', { expr = true, noremap = true }) require("blink.cmp").setup {
vim.api.nvim_set_keymap('i', '<S-Tab>', '<C-n>', { noremap = true }) keymap = {
preset = "none",
["<Tab>"] = {
function(cmp)
if not has_words_before() then
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<Tab>", true, true, true), "n", false)
return true
end
end,
"show", "select_next", "fallback" },
["<S-Tab>"] = { "show", "select_prev", "fallback" },
},
fuzzy = { implementation = "prefer_rust_with_warning" },
completion = {
menu = { auto_show = false },
list = { selection = { preselect = false, auto_insert = true }, cycle = { from_top = true } },
},
}