emmet
emmet copied to clipboard
it doesn't work for me with `vsnip`
when I open a file in html or css, when I see the information with LspInfo
it appears that it is running, however the autocomplete does not work
My LSP config:
" LSP
syntax enable
filetype plugin indent on
set completeopt=menuone,noinsert,noselect
set shortmess+=c
lua <<EOF
-- Setup nvim-cmp.
local has_words_before = function()
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 cmp = require('cmp')
local lspkind = require('lspkind')
local lspconfig = require'lspconfig'
local configs = require'lspconfig.configs'
-- icons
local kind_icons = {
Text = "",
Method = "",
Function = "",
Constructor = "",
Field = "",
Variable = "",
Class = "ﴯ",
Interface = "",
Module = "",
Property = "ﰠ",
Unit = "",
Value = "",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = ""
}
-- Setup CMP
cmp.setup({
formatting = {
format = function(entry, vim_item)
-- Kind icons
vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind)
-- Source
vim_item.menu = ({
buffer = "[Buffer]",
nvim_lsp = "[LSP]",
luasnip = "[LuaSnip]",
nvim_lua = "[Lua]",
latex_symbols = "[LaTeX]",
})[entry.source.name]
return vim_item
end
},
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
mapping = {
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
['<CR>'] = cmp.mapping.confirm({ select = true }),
['<Tab>'] = function(fallback)
if not cmp.select_next_item() then
if vim.bo.buftype ~= 'prompt' and has_words_before() then
cmp.complete()
else
fallback()
end
end
end,
['<S-Tab>'] = function(fallback)
if not cmp.select_prev_item() then
if vim.bo.buftype ~= 'prompt' and has_words_before() then
cmp.complete()
else
fallback()
end
end
end,
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'vsnip' },
}, {
{ name = 'buffer' },
})
})
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline('/', {
sources = {
{ name = 'buffer' }
}
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
-- Setup lspconfig.
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
-- Rust
require('lspconfig')['rust_analyzer'].setup {
capabilities = capabilities
}
-- Python
require('lspconfig')['pyright'].setup {
capabilities = capabilities
}
-- C/C++
require('lspconfig')['clangd'].setup {
capabilities = capabilities
}
-- Tsserver
require('lspconfig')['tsserver'].setup {
capabilities = capabilities,
single_file_support = true
}
-- Vue
require('lspconfig')['vuels'].setup {
capabilities = capabilities
}
-- Html
require('lspconfig')['html'].setup {
capabilities = capabilities
}
-- Css
require('lspconfig')['cssls'].setup {
capabilities = capabilities
}
-- Golang
require('lspconfig')['gopls'].setup {
cmd = { "gopls" },
filetypes = { "go", "gomod", "gotmpl" },
root_dir = require("lspconfig").util.root_pattern{"*"},
}
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
if not configs.ls_emmet then
configs.ls_emmet = {
default_config = {
cmd = { 'ls_emmet', '--stdio' };
filetypes = {
'html',
'css',
'scss',
'javascript',
'javascriptreact',
'typescript',
'typescriptreact',
'haml',
'xml',
'xsl',
'pug',
'slim',
'sass',
'stylus',
'less',
'sss',
'hbs',
'handlebars',
};
root_dir = function(fname)
return vim.loop.cwd()
end;
settings = {};
};
}
end
lspconfig.ls_emmet.setup { capabilities = capabilities }
EOF
have you installed these plugins?
use 'hrsh7th/cmp-vsnip'
use 'hrsh7th/vim-vsnip'
use 'hrsh7th/vim-vsnip-integ'
Run this: :CmpStatus
and show me the output
yes, I have all the extensions installed. Plugs:
" LSP
Plug 'neovim/nvim-lspconfig'
Plug 'nvim-lua/lsp_extensions.nvim'
" LSP-AUTOCOMPLETION
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-path'
Plug 'hrsh7th/cmp-cmdline'
Plug 'hrsh7th/nvim-cmp'
Plug 'onsails/lspkind-nvim'
" CMP-SNIPPET
Plug 'hrsh7th/cmp-vsnip'
Plug 'hrsh7th/vim-vsnip'
Plug 'hrsh7th/vim-vsnip-integ'
this is the output of :CmpStatus
it works for me so it's definitely not a problem with the language server you can check out my config to see how I do it
what if you manually call for complation with ctrl-space
@SrWither
I don't need to do that
What's your "cot" option?
:set cot?
@max397574
menuone,noselect
what if you manually call for complation with
ctrl-space
@SrWither
it does not work
i changed vsnip to luasnip and now it works
no html autocomplete unless you hit
<
though that's from the html lang server
@max397574 are you using vsnip?
For me it's working with vsnip
, I don't know why your config doesn't
I'm using luasnip
I'm going to leave this issue open, to see if anyone else have the same problem