native #1
2 changed files with 21 additions and 52 deletions
scratch native completion and go with blink.cmp
commit
1b851a35d8
64
init.lua
64
init.lua
|
|
@ -34,11 +34,23 @@ vim.pack.add({
|
||||||
"https://github.com/vyfor/cord.nvim",
|
"https://github.com/vyfor/cord.nvim",
|
||||||
"https://github.com/mason-org/mason-lspconfig.nvim.git",
|
"https://github.com/mason-org/mason-lspconfig.nvim.git",
|
||||||
"https://github.com/mason-org/mason.nvim.git",
|
"https://github.com/mason-org/mason.nvim.git",
|
||||||
|
{ src = "https://github.com/Saghen/blink.cmp", version = "v1" },
|
||||||
})
|
})
|
||||||
|
|
||||||
vim.lsp.config("qmlls", {
|
vim.lsp.config("qmlls", {
|
||||||
cmd = { "qmlls6" },
|
cmd = { "qmlls6" },
|
||||||
})
|
})
|
||||||
|
require("blink.cmp").setup({
|
||||||
|
fuzzy = { implementation = "prefer_rust_with_warning" },
|
||||||
|
completion = {
|
||||||
|
menu = {
|
||||||
|
auto_show = false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
sources = {
|
||||||
|
default = { "lsp", "path", "snippets", "buffer" },
|
||||||
|
},
|
||||||
|
})
|
||||||
require("mason").setup()
|
require("mason").setup()
|
||||||
require("mason-lspconfig").setup()
|
require("mason-lspconfig").setup()
|
||||||
require("bufferline").setup({
|
require("bufferline").setup({
|
||||||
|
|
@ -46,7 +58,7 @@ require("bufferline").setup({
|
||||||
themable = true,
|
themable = true,
|
||||||
numbers = "ordinal",
|
numbers = "ordinal",
|
||||||
indicator = {
|
indicator = {
|
||||||
icon = '',
|
icon = "",
|
||||||
style = "underline",
|
style = "underline",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -89,6 +101,7 @@ require("lualine").setup({
|
||||||
lualine_z = { "location" },
|
lualine_z = { "location" },
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- keymaps
|
-- keymaps
|
||||||
local map = vim.keymap.set
|
local map = vim.keymap.set
|
||||||
|
|
||||||
|
|
@ -133,55 +146,6 @@ map("n", "<leader>t", "<cmd> terminal <cr>")
|
||||||
map("n", "<A-t>", "<cmd>Lspsaga term_toggle<cr>")
|
map("n", "<A-t>", "<cmd>Lspsaga term_toggle<cr>")
|
||||||
map("t", "<esc>", "<c-\\><c-n>")
|
map("t", "<esc>", "<c-\\><c-n>")
|
||||||
map("i", "<C-space>", vim.lsp.completion.get, { desc = "trigger autocompletion" })
|
map("i", "<C-space>", vim.lsp.completion.get, { desc = "trigger autocompletion" })
|
||||||
-- lsp setup
|
|
||||||
vim.lsp.config("*", {
|
|
||||||
on_attach = function(client, bufnr)
|
|
||||||
vim.lsp.completion.enable(true, client.id, bufnr, {
|
|
||||||
autotrigger = true,
|
|
||||||
convert = function(item)
|
|
||||||
return { abbr = item.label:gsub("%b()", "") }
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
vim.keymap.set("i", "<C-space>", vim.lsp.completion.get, { desc = "trigger autocompletion" })
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.o.complete = ".,o" -- use buffer and omnifunc
|
|
||||||
vim.o.completeopt = "fuzzy,menuone,noselect" -- add 'popup' for docs (sometimes)
|
|
||||||
vim.o.autocomplete = true
|
|
||||||
vim.o.pumheight = 7
|
|
||||||
|
|
||||||
-- setup autocomplete
|
|
||||||
vim.api.nvim_create_autocmd("LspAttach", {
|
|
||||||
callback = function(ev)
|
|
||||||
vim.lsp.completion.enable(true, ev.data.client_id, ev.buf, {
|
|
||||||
-- Optional formating of items
|
|
||||||
convert = function(item)
|
|
||||||
-- Remove leading misc chars for abbr name,
|
|
||||||
-- and cap field to 25 chars
|
|
||||||
--local abbr = item.label
|
|
||||||
--abbr = abbr:match("[%w_.]+.*") or abbr
|
|
||||||
--abbr = #abbr > 25 and abbr:sub(1, 24) .. "…" or abbr
|
|
||||||
--
|
|
||||||
-- Remove return value
|
|
||||||
--local menu = ""
|
|
||||||
|
|
||||||
-- Only show abbr name, remove leading misc chars (bullets etc.),
|
|
||||||
-- and cap field to 15 chars
|
|
||||||
local abbr = item.label
|
|
||||||
abbr = abbr:gsub("%b()", ""):gsub("%b{}", "")
|
|
||||||
abbr = abbr:match("[%w_.]+.*") or abbr
|
|
||||||
abbr = #abbr > 15 and abbr:sub(1, 14) .. "…" or abbr
|
|
||||||
|
|
||||||
-- Cap return value field to 15 chars
|
|
||||||
local menu = item.detail or ""
|
|
||||||
menu = #menu > 15 and menu:sub(1, 14) .. "…" or menu
|
|
||||||
|
|
||||||
return { abbr = abbr, menu = menu }
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
-- tinty function
|
-- tinty function
|
||||||
local default_theme = "base16-oceanicnext"
|
local default_theme = "base16-oceanicnext"
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,11 @@
|
||||||
"rev": "190397833e53fdfd5cf400c5baaf1a4e533158e5",
|
"rev": "190397833e53fdfd5cf400c5baaf1a4e533158e5",
|
||||||
"src": "https://github.com/RRethy/base16-nvim"
|
"src": "https://github.com/RRethy/base16-nvim"
|
||||||
},
|
},
|
||||||
|
"blink.cmp": {
|
||||||
|
"rev": "78336bc89ee5365633bcf754d93df01678b5c08f",
|
||||||
|
"src": "https://github.com/Saghen/blink.cmp",
|
||||||
|
"version": "'v1'"
|
||||||
|
},
|
||||||
"bufferline.nvim": {
|
"bufferline.nvim": {
|
||||||
"rev": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3",
|
"rev": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3",
|
||||||
"src": "https://github.com/akinsho/bufferline.nvim"
|
"src": "https://github.com/akinsho/bufferline.nvim"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue