From 2f4166f9efabba008e6efab80bb4f3d2e861f842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Hamal=20Dvo=C5=99=C3=A1k?= Date: Sun, 15 Feb 2026 13:52:25 +0100 Subject: [PATCH] Use blink.cmp & tsgo --- .gitmodules | 3 +++ bundle/blink.cmp | 1 + init.vim | 2 +- lua/init.lua | 67 +++++++++++++++++++++++++++++++++++++++--------- 4 files changed, 60 insertions(+), 13 deletions(-) create mode 160000 bundle/blink.cmp diff --git a/.gitmodules b/.gitmodules index 10f11ff..22084f5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -25,3 +25,6 @@ [submodule "bundle/conform"] path = bundle/conform url = https://github.com/stevearc/conform.nvim.git +[submodule "bundle/blink.cmp"] + path = bundle/blink.cmp + url = https://github.com/saghen/blink.cmp.git diff --git a/bundle/blink.cmp b/bundle/blink.cmp new file mode 160000 index 0000000..cd79f57 --- /dev/null +++ b/bundle/blink.cmp @@ -0,0 +1 @@ +Subproject commit cd79f572971c58784ca72551af29af3a63da9168 diff --git a/init.vim b/init.vim index 5368a3a..49c1f25 100644 --- a/init.vim +++ b/init.vim @@ -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 python setlocal ts=4 sw=4 et 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 BufNewFile,BufRead *.pio setfiletype pioasm diff --git a/lua/init.lua b/lua/init.lua index a416518..6e8eee1 100644 --- a/lua/init.lua +++ b/lua/init.lua @@ -139,9 +139,9 @@ vim.lsp.config("vtsls", { }, }, filetypes = { - "javascript", + -- "javascript", "javascriptreact", - "typescript", + -- "typescript", "typescriptreact", "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", { pattern = "vue", callback = function() @@ -193,17 +206,47 @@ vim.lsp.config("rust_analyzer", {}) -- end, -- }) -local function check_back_space() - local col = vim.fn.col('.') - 1 - return col <= 0 or vim.fn.getline('.'):sub(col, col):match('%s') -end +-- local function check_back_space() +-- local col = vim.fn.col('.') - 1 +-- return col <= 0 or vim.fn.getline('.'):sub(col, col):match('%s') +-- end +-- +-- function tab_complete() +-- if check_back_space() then +-- return vim.api.nvim_replace_termcodes('', true, false, true) +-- end +-- return vim.api.nvim_replace_termcodes('', true, false, true) +-- end +-- +-- vim.api.nvim_set_keymap('i', '', 'v:lua.tab_complete()', { expr = true, noremap = true }) +-- vim.api.nvim_set_keymap('i', '', '', { noremap = true }) -function tab_complete() - if check_back_space() then - return vim.api.nvim_replace_termcodes('', true, false, true) +local has_words_before = function() + local col = vim.api.nvim_win_get_cursor(0)[2] + if col == 0 then + return false end - return vim.api.nvim_replace_termcodes('', true, false, true) + local line = vim.api.nvim_get_current_line() + return line:sub(col, col):match("%s") == nil end -vim.api.nvim_set_keymap('i', '', 'v:lua.tab_complete()', { expr = true, noremap = true }) -vim.api.nvim_set_keymap('i', '', '', { noremap = true }) +require("blink.cmp").setup { + keymap = { + preset = "none", + + [""] = { + function(cmp) + if not has_words_before() then + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("", true, true, true), "n", false) + return true + end + end, + "show", "select_next", "fallback" }, + [""] = { "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 } }, + }, +}