Use blink.cmp & tsgo
This commit is contained in:
parent
295c49979e
commit
2f4166f9ef
4 changed files with 60 additions and 13 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
|
@ -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
|
||||
|
|
|
|||
1
bundle/blink.cmp
Submodule
1
bundle/blink.cmp
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit cd79f572971c58784ca72551af29af3a63da9168
|
||||
2
init.vim
2
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
|
||||
|
|
|
|||
67
lua/init.lua
67
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('<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()
|
||||
if check_back_space() then
|
||||
return vim.api.nvim_replace_termcodes('<Tab>', 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('<C-p>', 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', '<Tab>', 'v:lua.tab_complete()', { expr = true, noremap = true })
|
||||
vim.api.nvim_set_keymap('i', '<S-Tab>', '<C-n>', { noremap = true })
|
||||
require("blink.cmp").setup {
|
||||
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 } },
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue