-
Notifications
You must be signed in to change notification settings - Fork 389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Param snippet doesn't show. #852
Labels
bug
Something isn't working
Comments
You should specify Could you create the wiki entry for it? I can't support all of LSP servers. |
@hrsh7th Thanks, the |
Just in case anyone wants a minimal configuration using local fn = vim.fn
local cmd = vim.cmd
-- Boostrap Packer
local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
local packer_bootstrap
if fn.empty(fn.glob(install_path)) > 0 then
packer_bootstrap = fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
end
-- Rerun PackerCompile everytime pluggins.lua is updated
cmd([[
augroup packer_user_config
autocmd!
autocmd BufWritePost plugins.lua source <afile> | PackerCompile
augroup end
]])
-- Load Packer
cmd([[packadd packer.nvim]])
-- Initialize pluggins
require('packer').startup(function(use)
-- Let Packer manage itself
use 'wbthomason/packer.nvim'
--lsp
use 'neovim/nvim-lspconfig'
use 'williamboman/nvim-lsp-installer'
--audo complete
use 'hrsh7th/cmp-nvim-lsp'
use 'hrsh7th/cmp-buffer'
use 'hrsh7th/cmp-path'
use 'hrsh7th/cmp-cmdline'
use 'hrsh7th/nvim-cmp'
--
use 'hrsh7th/cmp-vsnip'
use 'hrsh7th/vim-vsnip'
use 'onsails/lspkind-nvim'
use 'rafamadriz/friendly-snippets'
vim.opt.completeopt = { "menu", "menuone", "noselect" }
if packer_bootstrap then
require('packer').sync()
end
end)
local cmp = require('cmp')
local lspkind = require('lspkind')
cmp.setup({
snippet = {
expand = function (args)
vim.fn['vsnip#anonymous'](args.body)
end
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'vsnip' }
}, {
{ name = 'buffer' },
{ name = 'path' }
}),
formatting = {
format = lspkind.cmp_format({
mode = "symbol_text",
with_text = true,
}),
},
mapping = {
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
['<C-e>'] = cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
}),
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
},
})
local function buf_map(bufnr, mode, lhs, rhs)
vim.api.nvim_buf_set_keymap(bufnr, mode, lhs, rhs, { noremap = true, silent = true })
end
local function bufmap_keys(bufnr, mappings)
for _, map in ipairs(mappings) do
local mode, lhs, rhs = map[1], map[2], map[3]
buf_map(bufnr, mode, lhs, rhs)
end
end
local lsp_installer = require('nvim-lsp-installer')
local servers = {
'gopls'
}
vim.diagnostic.config({
virtual_text = false,
signs = true,
underline = true,
update_in_insert = false,
severity_sort = false,
})
-- Sign column
local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " }
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
end
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
capabilities.textDocument.completion.completionItem.snippetSupport = true
capabilities.textDocument.completion.completionItem.resolveSupport = {
properties = {
'documentation',
'detail',
'additionalTextEdits',
}
}
local function on_attach(client, bufnr)
-- Enable completion triggered by <c-x><c-o>
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Formatting file on save
if client.resolved_capabilities.document_formatting then
vim.cmd([[
augroup LspFormatting
autocmd! * <buffer>
autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()
augroup END
]])
end
if client.resolved_capabilities.document_highlight then
vim.api.nvim_exec([[
augroup lsp_document_highlight
autocmd! * <buffer>
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
augroup END
]], false)
end
-- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
bufmap_keys(bufnr, {
{'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>'},
{'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>'},
{'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>'},
{'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>'},
{'n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>'},
{'n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>'},
{'n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>'},
{'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>'},
{'n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>'},
{'n', '<space>cc', '<cmd>lua vim.diagnostic.open_float(nil, {focus=false, scope="cursor"})<CR>'},
})
end
lsp_installer.settings({
log_level = vim.log.levels.DEBUG,
ui = {
icons = {
server_installed = "",
server_pending = "",
server_uninstalled = "",
},
},
})
for _, name in pairs(servers) do
local server_is_found, server = lsp_installer.get_server(name)
if server_is_found and not server:is_installed() then
print('Installing ' .. name)
server:install()
end
end
local server_opts = {
['gopls'] = function(opts)
opts.on_attach = function(client)
client.resolved_capabilities.document_formatting = false
client.resolved_capabilities.document_range_formatting = false
end
return opts
end
}
lsp_installer.on_server_ready(function(server)
local default_opts = {
on_attach = on_attach,
capabilities = capabilities
}
if server_opts[server.name] then
server_opts[server.name](default_opts)
end
server:setup(default_opts)
vim.cmd('do User LspAttachBuffers')
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FAQ
Issues
Neovim Version
v0.6.1
Minimal reproducible config
Description
The parameter snippet doesn't show after choosing a function. The config is copied form Recommended Configuration. I also tried the config from issue #706, still not work.
complete.mp4
Steps to reproduce
Pick a function from popup items.
Expected behavior
The param is displayed and possible to navigate through.
Actual behavior
No param displayed
Additional context
No response
The text was updated successfully, but these errors were encountered: