mirror of
https://github.com/tomru/nvim.git
synced 2026-03-04 06:57:15 +01:00
try blink.nvim instead of nvim-cmp
This commit is contained in:
@@ -1,101 +1,61 @@
|
|||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
'hrsh7th/nvim-cmp',
|
'saghen/blink.cmp',
|
||||||
lazy = false,
|
lazy = false, -- lazy loading handled internally
|
||||||
priority = 100,
|
-- optional: provides snippets for the snippet source
|
||||||
dependencies = {
|
dependencies = 'rafamadriz/friendly-snippets',
|
||||||
'hrsh7th/cmp-nvim-lsp',
|
|
||||||
'hrsh7th/cmp-path',
|
|
||||||
'hrsh7th/cmp-buffer',
|
|
||||||
{ 'L3MON4D3/LuaSnip', build = 'make install_jsregexp' },
|
|
||||||
'saadparwaiz1/cmp_luasnip',
|
|
||||||
'rafamadriz/friendly-snippets',
|
|
||||||
'zbirenbaum/copilot-cmp',
|
|
||||||
'onsails/lspkind.nvim',
|
|
||||||
},
|
|
||||||
config = function()
|
|
||||||
vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
|
|
||||||
vim.opt.shortmess:append 'c'
|
|
||||||
|
|
||||||
local cmp = require 'cmp'
|
-- use a release tag to download pre-built binaries
|
||||||
local lspkind = require 'lspkind'
|
version = 'v0.*',
|
||||||
|
-- OR build from source, requires nightly: https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust
|
||||||
|
-- build = 'cargo build --release',
|
||||||
|
-- If you use nix, you can build from source using latest nightly rust with:
|
||||||
|
-- build = 'nix run .#build-plugin',
|
||||||
|
|
||||||
cmp.setup {
|
---@module 'blink.cmp'
|
||||||
sources = {
|
---@type blink.cmp.Config
|
||||||
{ name = 'copilot' },
|
opts = {
|
||||||
{ name = 'luasnip' },
|
-- 'default' for mappings similar to built-in completion
|
||||||
{ name = 'nvim_lsp' },
|
-- 'super-tab' for mappings similar to vscode (tab to accept, arrow keys to navigate)
|
||||||
{ name = 'path' },
|
-- 'enter' for mappings similar to 'super-tab' but with 'enter' to accept
|
||||||
{ name = 'buffer' },
|
-- see the "default configuration" section below for full documentation on how to define
|
||||||
},
|
-- your own keymap.
|
||||||
mapping = {
|
keymap = { preset = 'default' },
|
||||||
['<C-n>'] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert },
|
|
||||||
['<C-p>'] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert },
|
|
||||||
['<C-y>'] = cmp.mapping(
|
|
||||||
cmp.mapping.confirm {
|
|
||||||
behavior = cmp.ConfirmBehavior.Insert,
|
|
||||||
select = true,
|
|
||||||
},
|
|
||||||
{ 'i', 'c' }
|
|
||||||
),
|
|
||||||
},
|
|
||||||
|
|
||||||
-- Enable luasnip to handle snippet expansion for nvim-cmp
|
highlight = {
|
||||||
snippet = {
|
-- sets the fallback highlight groups to nvim-cmp's highlight groups
|
||||||
expand = function(args)
|
-- useful for when your theme doesn't support blink.cmp
|
||||||
require('luasnip').lsp_expand(args.body)
|
-- will be removed in a future release, assuming themes add support
|
||||||
end,
|
use_nvim_cmp_as_default = true,
|
||||||
},
|
},
|
||||||
|
-- set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
|
||||||
|
-- adjusts spacing to ensure icons are aligned
|
||||||
|
nerd_font_variant = 'mono',
|
||||||
|
|
||||||
formatting = {
|
-- experimental auto-brackets support
|
||||||
expandable_indicator = true,
|
-- accept = { auto_brackets = { enabled = true } }
|
||||||
fields = { 'abbr', 'kind' },
|
|
||||||
format = lspkind.cmp_format {
|
|
||||||
mode = 'symbol_text', -- show only symbol annotations
|
|
||||||
maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
|
|
||||||
ellipsis_char = '...', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first)
|
|
||||||
show_labelDetails = true, -- show labelDetails in menu. Disabled by default
|
|
||||||
|
|
||||||
-- The function below will be called before any actual modifications from lspkind
|
-- experimental signature help support
|
||||||
-- so that you can provide more controls on popup customization. (See [#30](https://github.com/onsails/lspkind-nvim/pull/30))
|
-- trigger = { signature_help = { enabled = true } }
|
||||||
-- before = function(entry, vim_item)
|
|
||||||
-- return vim_item
|
|
||||||
-- end,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
|
||||||
|
|
||||||
-- Setup up vim-dadbod
|
-- LSP servers and clients communicate what features they support through "capabilities".
|
||||||
cmp.setup.filetype({ 'sql' }, {
|
-- By default, Neovim support a subset of the LSP specification.
|
||||||
sources = {
|
-- With blink.cmp, Neovim has *more* capabilities which are communicated to the LSP servers.
|
||||||
{ name = 'vim-dadbod-completion' },
|
-- Explanation from TJ: https://youtu.be/m8C0Cq9Uv9o?t=1275
|
||||||
{ name = 'buffer' },
|
--
|
||||||
},
|
-- This can vary by config, but in-general for nvim-lspconfig:
|
||||||
})
|
|
||||||
|
|
||||||
local ls = require 'luasnip'
|
{
|
||||||
ls.config.set_config {
|
'neovim/nvim-lspconfig',
|
||||||
history = false,
|
dependencies = { 'saghen/blink.cmp' },
|
||||||
updateevents = 'TextChanged,TextChangedI',
|
config = function(_, opts)
|
||||||
}
|
local lspconfig = require 'lspconfig'
|
||||||
|
for server, config in pairs(opts.servers or {}) do
|
||||||
for _, ft_path in ipairs(vim.api.nvim_get_runtime_file('lua/custom/snippets/*.lua', true)) do
|
config.capabilities = require('blink.cmp').get_lsp_capabilities(config.capabilities)
|
||||||
loadfile(ft_path)()
|
lspconfig[server].setup(config)
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.keymap.set({ 'i', 's' }, '<c-k>', function()
|
|
||||||
if ls.expand_or_jumpable() then
|
|
||||||
ls.expand_or_jump()
|
|
||||||
end
|
|
||||||
end, { silent = true })
|
|
||||||
|
|
||||||
vim.keymap.set({ 'i', 's' }, '<c-j>', function()
|
|
||||||
if ls.jumpable(-1) then
|
|
||||||
ls.jump(-1)
|
|
||||||
end
|
|
||||||
end, { silent = true })
|
|
||||||
|
|
||||||
require('luasnip/loaders/from_vscode').lazy_load()
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ return {
|
|||||||
panel = { enabled = false },
|
panel = { enabled = false },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
-- {
|
||||||
'zbirenbaum/copilot-cmp',
|
-- 'zbirenbaum/copilot-cmp',
|
||||||
config = function()
|
-- config = function()
|
||||||
require('copilot_cmp').setup()
|
-- require('copilot_cmp').setup()
|
||||||
end,
|
-- end,
|
||||||
},
|
-- },
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,23 +14,25 @@ return {
|
|||||||
|
|
||||||
-- Schema information
|
-- Schema information
|
||||||
'b0o/SchemaStore.nvim',
|
'b0o/SchemaStore.nvim',
|
||||||
},
|
|
||||||
config = function()
|
|
||||||
local util = require 'lspconfig.util'
|
|
||||||
|
|
||||||
require('neodev').setup {
|
-- cmp
|
||||||
|
'saghen/blink.cmp',
|
||||||
|
},
|
||||||
|
config = function(_, opts)
|
||||||
|
-- require('neodev').setup {
|
||||||
-- library = {
|
-- library = {
|
||||||
-- plugins = { "nvim-dap-ui" },
|
-- plugins = { "nvim-dap-ui" },
|
||||||
-- types = true,
|
-- types = true,
|
||||||
-- },
|
-- },
|
||||||
}
|
-- }
|
||||||
|
--
|
||||||
local capabilities = nil
|
local lspconfig = require 'lspconfig'
|
||||||
if pcall(require, 'cmp_nvim_lsp') then
|
for server, config in pairs(opts.servers or {}) do
|
||||||
capabilities = require('cmp_nvim_lsp').default_capabilities()
|
config.capabilities = require('blink.cmp').get_lsp_capabilities(config.capabilities)
|
||||||
|
lspconfig[server].setup(config)
|
||||||
end
|
end
|
||||||
|
|
||||||
local lspconfig = require 'lspconfig'
|
local util = require 'lspconfig.util'
|
||||||
|
|
||||||
local servers = {
|
local servers = {
|
||||||
bashls = true,
|
bashls = true,
|
||||||
@@ -39,6 +41,8 @@ return {
|
|||||||
svelte = true,
|
svelte = true,
|
||||||
templ = true,
|
templ = true,
|
||||||
cssls = true,
|
cssls = true,
|
||||||
|
eslint = true,
|
||||||
|
ast_grep = true,
|
||||||
|
|
||||||
ts_ls = {
|
ts_ls = {
|
||||||
root_dir = function(fname)
|
root_dir = function(fname)
|
||||||
|
|||||||
9
lua/plugins/snippets.lua
Normal file
9
lua/plugins/snippets.lua
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
return {
|
||||||
|
'L3MON4D3/LuaSnip',
|
||||||
|
version = 'v2.*',
|
||||||
|
run = 'make install_jsregexp',
|
||||||
|
dependencies = { 'rafamadriz/friendly-snippets' },
|
||||||
|
init = function()
|
||||||
|
require('luasnip.loaders.from_vscode').lazy_load()
|
||||||
|
end,
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user