Comments (2)
Change the name of your sources. Like this.
sources = {
{name = 'nvim_lsp'},
{name = 'path'},
{name = 'buffer'},
{name = 'luasnip'},
},
You need to make sure you have all these plugins installed:
- hrsh7th/cmp-nvim-lsp
- hrsh7th/cmp-buffer
- hrsh7th/cmp-path
- saadparwaiz1/cmp_luasnip
- rafamadriz/friendly-snippets
And add the luasnip loader in your config.
require('luasnip.loaders.from_vscode').lazy_load()
from lsp-zero.nvim.
The plugin is working perfectly now, and I'm back to coding smoothly.
Thanks again for your fantastic work!
I'm attaching my configuration files related to the lsp-zero plugin. I hope they can be useful for other users facing similar issues.
packer.lua:
use {
'VonHeikemen/lsp-zero.nvim',
branch = 'v2.x',
requires = {
-- LSP Support
{'neovim/nvim-lspconfig'}, -- Required
{ -- Optional
'williamboman/mason.nvim',
run = function()
pcall(vim.api.nvim_command, 'MasonUpdate')
end,
},
{'williamboman/mason-lspconfig.nvim'}, -- Optional
-- Autocompletion
{'hrsh7th/nvim-cmp'}, -- Required
{'hrsh7th/cmp-nvim-lsp'}, -- Required
{'L3MON4D3/LuaSnip'}, -- Required
{"rafamadriz/friendly-snippets"},
{"saadparwaiz1/cmp_luasnip"},
{"hrsh7th/cmp-buffer"},
--lspkind
{"onsails/lspkind-nvim"},
}
}
lsp.lua
local lsp = require('lsp-zero').preset({"recommended"})
-- Fix Undefined global 'vim'
lsp.configure('lua_ls', {
settings = {
Lua = {
diagnostics = {
globals = { 'vim' }
}
}
}
})
lsp.on_attach(function(client, bufnr)
-- see :help lsp-zero-keybindings
-- to learn the available actions
lsp.default_keymaps({buffer = bufnr})
-- Neovim LSP Pickers
-- https://github.com/nvim-telescope/telescope.nvim#neovim-lsp-pickers
vim.keymap.set('n', 'gr', '<cmd>Telescope lsp_references<cr>', {buffer = true})
vim.keymap.set('n', 'gs', '<cmd>Telescope lsp_document_symbols<cr>', {buffer = true})
vim.keymap.set('n', 'gD', '<cmd>Telescope lsp_implementations<cr>', {buffer = true})
vim.keymap.set('n', 'gd', '<cmd>Telescope lsp_definitions<cr>', {buffer = true})
end)
-- list: https://github.com/williamboman/mason-lspconfig.nvim
lsp.ensure_installed({
"clangd",
"lua_ls",
"marksman",
"pyre",
"rust_analyzer",
"cmake",
"bashls",
"lemminx",
"ltex",
"jsonls",
"docker_compose_language_service",
})
lsp.set_sign_icons({
error = '✘',
warn = '▲',
hint = '⚑',
info = ''
})
--formatter
--cf is using 2 space as a tab :(
-- FIXME: modify clang formatter
-- lsp.format_on_save({
-- format_opts = {
-- async = false,
-- timeout_ms = 10000,
-- },
-- servers = {
-- ['clangd'] = {'cpp'},
-- }
-- })
-- keybinding
lsp.setup()
-- ####### CMP ######## --
local cmp = require('cmp')
local cmp_action = require('lsp-zero').cmp_action()
cmp.setup({
-- sources
select_behavior = 'insert',
sources = {
{name = 'nvim_lsp'},
{name = 'path'},
{name = 'buffer'},
{name = 'luasnip'},
},
-- key-mapping
mapping = {
["<Tab>"] = cmp_action.luasnip_supertab(),
["<S-Tab>"] = cmp_action.luasnip_shift_supertab(),
-- `Enter` key to confirm completion
['<CR>'] = cmp.mapping.confirm({select = false}),
-- Ctrl+Space to trigger completion menu
['<C-Space>'] = cmp.mapping.complete(),
-- Navigate between snippet placeholder
['<C-f>'] = cmp_action.luasnip_jump_forward(),
['<C-b>'] = cmp_action.luasnip_jump_backward(),
['<C-e>'] = cmp.mapping.abort(),
['<C-u>'] = cmp.mapping.scroll_docs(-4),
['<C-d>'] = cmp.mapping.scroll_docs(4),
},
--snippets
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
--windows
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
--formating
formatting = {
fields = {'abbr', 'kind', 'menu'},
format = require('lspkind').cmp_format({
mode = 'symbol_text', -- show only symbol annotations
maxwidth = 50, -- prevent the popup from showing more than provided characters
ellipsis_char = '...', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead
})
},
})
require('luasnip.loaders.from_vscode').lazy_load()
from lsp-zero.nvim.
Related Issues (20)
- error installing gopls(same thing happend with hls) HOT 2
- error installing hls(haskell server) HOT 1
- Allow setting max width on vim.diagnostics
- Add docs or possible fix for Volar 2? HOT 4
- method textDocument/definition is not supported by any of the servers registered for the current buffer HOT 6
- Hi @VonHeikemen, came here after an year coz it was unmaintained, i grew up a lot in this time period, help me get back to `lsp-zero` HOT 3
- Undercurls to display errors HOT 2
- How do I turn off inlay hints? HOT 2
- Cannot get auto complete to work HOT 5
- How to configure efm? HOT 1
- Duplicate prefixes HOT 1
- lsp-zero conflict with noice shipped in LazyVim HOT 2
- Function signature helper HOT 1
- lsp server seem to be configured before .extend_lspconfig() HOT 4
- Question: Doc site HOT 2
- Error: failed to run 'config' for nvim-lspconfig HOT 3
- default keymaps not working correctly HOT 3
- lua-lsp is not working HOT 1
- No autocompletion HOT 2
- How to configure html lsp? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lsp-zero.nvim.