mirror of
https://github.com/js0ny/dotfiles.git
synced 2025-12-21 08:43:00 +00:00
feat(nvim): Change completion source to blink.cmp
* fix: Completion does not work under Linux * chore: Load less LSPs * feat: Add selection border for completions
This commit is contained in:
parent
47197902c8
commit
569238e45f
5 changed files with 112 additions and 18 deletions
|
|
@ -1,8 +1,9 @@
|
||||||
return {
|
return {
|
||||||
{ import = "plugins.mod.nvim-cmp" },
|
-- { import = "plugins.mod.nvim-cmp" },
|
||||||
{
|
-- {
|
||||||
"saadparwaiz1/cmp_luasnip",
|
-- "saadparwaiz1/cmp_luasnip",
|
||||||
},
|
-- },
|
||||||
|
{ import = "plugins.mod.blink-cmp" },
|
||||||
{
|
{
|
||||||
"L3MON4D3/LuaSnip",
|
"L3MON4D3/LuaSnip",
|
||||||
build = "make install_jsregexp",
|
build = "make install_jsregexp",
|
||||||
|
|
@ -11,8 +12,6 @@ return {
|
||||||
require("luasnip.loaders.from_vscode").lazy_load({ paths = "~/.config/lsp-snippets" })
|
require("luasnip.loaders.from_vscode").lazy_load({ paths = "~/.config/lsp-snippets" })
|
||||||
-- require("luasnip.loaders.from_vscode").lazy_load()
|
-- require("luasnip.loaders.from_vscode").lazy_load()
|
||||||
end,
|
end,
|
||||||
-- TODO: Remove this, simply delete this will let nvim-cmp not work
|
|
||||||
-- dependencies = { "rafamadriz/friendly-snippets" },
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"zbirenbaum/copilot-cmp",
|
"zbirenbaum/copilot-cmp",
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,5 @@
|
||||||
return {
|
return {
|
||||||
{
|
{ import = "plugins.mod.nvim-lspconfig" },
|
||||||
"neovim/nvim-lspconfig",
|
|
||||||
lazy = false,
|
|
||||||
},
|
|
||||||
{ import = "plugins.mod.render-markdown" },
|
{ import = "plugins.mod.render-markdown" },
|
||||||
-- { import = "plugins.mod.markview" },
|
-- { import = "plugins.mod.markview" },
|
||||||
{
|
{
|
||||||
|
|
|
||||||
64
tools/nvim/lua/plugins/mod/blink-cmp.lua
Normal file
64
tools/nvim/lua/plugins/mod/blink-cmp.lua
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
return {
|
||||||
|
"saghen/blink.cmp",
|
||||||
|
-- optional: provides snippets for the snippet source
|
||||||
|
dependencies = { "L3MON4D3/LuaSnip", version = "v2.*" },
|
||||||
|
|
||||||
|
-- use a release tag to download pre-built binaries
|
||||||
|
version = "*",
|
||||||
|
|
||||||
|
---@module 'blink.cmp'
|
||||||
|
---@type blink.cmp.Config
|
||||||
|
opts = {
|
||||||
|
keymap = {
|
||||||
|
preset = "default",
|
||||||
|
["<Tab>"] = {
|
||||||
|
function(cmp)
|
||||||
|
if cmp.snippet_active() then
|
||||||
|
return cmp.accept()
|
||||||
|
else
|
||||||
|
return cmp.select_and_accept()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
"snippet_forward",
|
||||||
|
"fallback",
|
||||||
|
},
|
||||||
|
["<C-f>"] = { "select_and_accept" },
|
||||||
|
["<C-b>"] = { "hide", "fallback" },
|
||||||
|
["<CR>"] = { "accept", "fallback" },
|
||||||
|
},
|
||||||
|
completion = {
|
||||||
|
menu = { border = "single" },
|
||||||
|
documentation = { window = { border = "single" } },
|
||||||
|
},
|
||||||
|
signature = { window = { border = "single" } },
|
||||||
|
|
||||||
|
appearance = {
|
||||||
|
-- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
|
||||||
|
-- Adjusts spacing to ensure icons are aligned
|
||||||
|
nerd_font_variant = "normal",
|
||||||
|
},
|
||||||
|
|
||||||
|
snippets = {
|
||||||
|
preset = "luasnip",
|
||||||
|
},
|
||||||
|
|
||||||
|
sources = {
|
||||||
|
default = { "lazydev", "lsp", "path", "snippets", "buffer" },
|
||||||
|
providers = {
|
||||||
|
lazydev = {
|
||||||
|
name = "LazyDev",
|
||||||
|
module = "lazydev.integrations.blink",
|
||||||
|
score_offset = 100,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
-- (Default) Rust fuzzy matcher for typo resistance and significantly better performance
|
||||||
|
-- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation,
|
||||||
|
-- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"`
|
||||||
|
--
|
||||||
|
-- See the fuzzy documentation for more information
|
||||||
|
fuzzy = { implementation = "prefer_rust_with_warning" },
|
||||||
|
},
|
||||||
|
opts_extend = { "sources.default" },
|
||||||
|
}
|
||||||
|
|
@ -1,11 +1,3 @@
|
||||||
local function set_keymaps(keymaps_cmp)
|
|
||||||
local mappings = {}
|
|
||||||
for _, map in ipairs(keymaps_cmp) do
|
|
||||||
mappings[map.keys] = map.cmd
|
|
||||||
end
|
|
||||||
return mappings
|
|
||||||
end
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"hrsh7th/nvim-cmp",
|
"hrsh7th/nvim-cmp",
|
||||||
-- lazy = false,
|
-- lazy = false,
|
||||||
|
|
|
||||||
42
tools/nvim/lua/plugins/mod/nvim-lspconfig.lua
Normal file
42
tools/nvim/lua/plugins/mod/nvim-lspconfig.lua
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
return {
|
||||||
|
"neovim/nvim-lspconfig",
|
||||||
|
dependencies = { "saghen/blink.cmp" },
|
||||||
|
|
||||||
|
-- example using `opts` for defining servers
|
||||||
|
opts = {
|
||||||
|
servers = {
|
||||||
|
lua_ls = {},
|
||||||
|
bashls = {},
|
||||||
|
clangd = {},
|
||||||
|
eslint = {}, -- JavaScript
|
||||||
|
gopls = {}, -- Go
|
||||||
|
jsonls = {}, -- JSON
|
||||||
|
markdown_oxide = {}, -- Markdown
|
||||||
|
omnisharp = {}, -- C# & F#
|
||||||
|
powershell_es = {}, -- PowerShell
|
||||||
|
pyright = {}, -- Python
|
||||||
|
taplo = {}, -- TOML
|
||||||
|
ts_ls = {}, -- TypeScript
|
||||||
|
vimls = {}, -- vimscript
|
||||||
|
yamlls = {}, -- YAML
|
||||||
|
beancount = {}, -- Beancount
|
||||||
|
},
|
||||||
|
},
|
||||||
|
config = function(_, opts)
|
||||||
|
local lspconfig = require("lspconfig")
|
||||||
|
for server, config in pairs(opts.servers) do
|
||||||
|
-- passing config.capabilities to blink.cmp merges with the capabilities in your
|
||||||
|
-- `opts[server].capabilities, if you've defined it
|
||||||
|
config.capabilities = require("blink.cmp").get_lsp_capabilities(config.capabilities)
|
||||||
|
lspconfig[server].setup(config)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
|
-- example calling setup directly for each LSP
|
||||||
|
-- config = function()
|
||||||
|
-- local capabilities = require('blink.cmp').get_lsp_capabilities()
|
||||||
|
-- local lspconfig = require('lspconfig')
|
||||||
|
--
|
||||||
|
-- lspconfig['lua_ls'].setup({ capabilities = capabilities })
|
||||||
|
-- end
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue