tsserver is not showing snippets when i type a simple word. like funtion
. i gotta activate tab then only snippets is provided…
lsp config:
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
-- Icons
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
vim.diagnostic.config({
virtual_text = true,
signs = true,
underline = true,
update_in_insert = true,
severity_sort = true,
})
-- html
require'lspconfig'.html.setup {
cmd = { "vscode-html-language-server.cmd", "--stdio" },
capabilities = capabilities,
}
-- scss/css/ls
require'lspconfig'.cssls.setup {
cmd = { "vscode-css-language-server.cmd", "--stdio" },
capabilities = capabilities,
}
-- js/typescript
require'lspconfig'.tsserver.setup{
cmd = { "typescript-language-server.cmd", "--stdio" },
capabilities = capabilities,
filetypes = { "javascript", "javascriptreact", "javascript.jsx", "typescript", "typescriptreact", "typescript.tsx" }
}
-- lua
local system_name
if vim.fn.has("mac") == 1 then
system_name = "macOS"
elseif vim.fn.has("unix") == 1 then
system_name = "Linux"
elseif vim.fn.has('win32') == 1 then
system_name = "Windows"
else
print("Your system doesnt support sumneko_lua.")
end
-- set the path to the sumneko installation; if you previously installed via the now deprecated :LspInstall, use
local sumneko_root_path = 'D:/projects/lua-language-server'
local sumneko_binary = sumneko_root_path.."/bin/"..system_name.."/lua-language-server"
local runtime_path = vim.split(package.path, ';')
table.insert(runtime_path, "lua/?.lua")
table.insert(runtime_path, "lua/?/init.lua")
require'lspconfig'.sumneko_lua.setup {
cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"};
settings = {
Lua = {
runtime = {
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
version = 'LuaJIT',
-- Setup your lua path
path = runtime_path,
},
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = {'vim'},
},
workspace = {
-- Make the server aware of Neovim runtime files
library = vim.api.nvim_get_runtime_file("", true),
checkThirdParty = false,
},
-- Do not send telemetry data containing a randomized but unique identifier
telemetry = {
enable = false,
},
},
},
}
cmp config:
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
local feedkey = function(key, mode)
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
end
local lspkind = require('lspkind')
local cmp = require'cmp'
cmp.setup({
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
end,
},
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 }),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif vim.fn["vsnip#available"](1) == 1 then
feedkey("<Plug>(vsnip-expand-or-jump)", "")
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function()
if cmp.visible() then
cmp.select_prev_item()
elseif vim.fn["vsnip#jumpable"](-1) == 1 then
feedkey("<Plug>(vsnip-jump-prev)", "")
end
end, { "i", "s" }),
},
formatting = {
format = lspkind.cmp_format {
with_text = true,
menu = {
buffer = "[BUF]",
nvim_lsp = "[LSP]",
nvim_lua = "[API]",
path = "[PATH]",
vsnip = "[SNIP]",
npm = "[NPM]"
},
},
},
sources = cmp.config.sources({
{ name = 'nvim_lsp', keyword_length = 4 },
{ name = 'lspkind' },
{ name = 'vsnip' },
{ name = 'buffer', keyword_length = 5 },
{ name = 'npm', keyword_length = 5}
}),
})
cmp.setup.cmdline('/', {
sources = {
{ name = 'buffer' }
}
})
HELP IS NEEDED