Skip to content
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

I can't use Emmet #286

Open
marcograhl opened this issue Apr 21, 2021 · 23 comments
Open

I can't use Emmet #286

marcograhl opened this issue Apr 21, 2021 · 23 comments

Comments

@marcograhl
Copy link

@marcograhl marcograhl commented Apr 21, 2021

How Can I enable Emmet < C - y > , is not doing much for me. Anybody uses Emmet with LunarVim and has a hint?

@rebuilt
Copy link
Contributor

@rebuilt rebuilt commented Apr 21, 2021

Assuming you have everything installed correctly, got to ./lua/settings.lua and comment out line 35.

-- vim.o.timeoutlen = 100

This is tip from the emmet project

FAQ
    Pressing ctrl+y+, doesn't work

    Probably you set timeoutlen=0. Most of Vim plugins which using key-mappings does not work with timeoutlen=0.
@ChristianChiarulli
Copy link
Owner

@ChristianChiarulli ChristianChiarulli commented Apr 21, 2021

I recommend emmet-ls, right now you need to globally install npm i -g emmet-ls

@marcograhl
Copy link
Author

@marcograhl marcograhl commented Apr 22, 2021

Thx for the fast reply, I did install emmet-ls do I need to Install it with Packer too? I mean the use and require you did with the outer plugins? I sometimes get an autocompletion randomly, I don't know if I'm doing the ctrl-y +, right :). Sometimes there is an autocompletion with Lsp Emmet without me doing anything. Im just a little confused, the resulting snippit is wrongly indented as well. I will dig deeper , cause I love the work you put in, its nice to have "default nvim" this beautifull. Thx Chris

@marcograhl
Copy link
Author

@marcograhl marcograhl commented Apr 22, 2021

Is there a way I can see if the keybind ctrl-y , is actually being used by emmet? I tried :verbose map , and no mapping was found. kind regards from Germany

@rebuilt
Copy link
Contributor

@rebuilt rebuilt commented Apr 22, 2021

    :nmap for normal mode mappings
    :vmap for visual mode mappings
    :imap for insert mode mappings

Try this instead

:verbose imap <C-y>
@marcograhl
Copy link
Author

@marcograhl marcograhl commented Apr 22, 2021

Its not mapped to anything weird. I didn't change anything from the starter files. I got Lsp working and its beautifull => love the preview popup window omg. I installed emmet-ls globaly.. mhh is there a step I missed.

@rebuilt
Copy link
Contributor

@rebuilt rebuilt commented Apr 22, 2021

I haven't set it up myself but according to the docs you need something like this in your configs

local nvim_lsp = require'lspconfig'
local configs = require'lspconfig/configs'
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true

configs.emmet_ls = {
  default_config = {
    cmd = {'emmet-ls', '--stdio'};
    filetypes = {'html', 'css'};
    root_dir = function()
      return vim.loop.cwd()
    end;
    settings = {};
  };
}

nvim_lsp.emmet_ls.setup{
  on_attach = on_attach;
}
@rebuilt
Copy link
Contributor

@rebuilt rebuilt commented Apr 22, 2021

I just set it up for myself. It looks like its turned 'off' by default.
Uncomment the following line in lua/lsp/emmet-ls.lua, line 18

on_attach = on_attach
@marcograhl
Copy link
Author

@marcograhl marcograhl commented Apr 22, 2021

I tried that but I still won't get a mapping, does it work for you, when you type < c - y>, ? I will try maybe another leader key and see if this does anything. Thanks for your patience

@rebuilt
Copy link
Contributor

@rebuilt rebuilt commented Apr 22, 2021

Did the output of the following command change?
:verbose imap <c-y>

@marcograhl
Copy link
Author

@marcograhl marcograhl commented Apr 22, 2021

I get no mapping found mhh

@rebuilt
Copy link
Contributor

@rebuilt rebuilt commented Apr 22, 2021

Make sure emmet is executable from the command line

@marcograhl
Copy link
Author

@marcograhl marcograhl commented Apr 22, 2021

how can I see that, what do I need to put into the command line?

@rebuilt
Copy link
Contributor

@rebuilt rebuilt commented Apr 22, 2021

What's the output of

which emmet-ls

Also make sure you're in an html file and not an html.erb file or something like that.

What is the output of

:LspInfo

It should contain an entry for emmet_ls

@marcograhl
Copy link
Author

@marcograhl marcograhl commented Apr 22, 2021

/usr/local/bin/emmet-ls
is the location

here is the image for LspInfo
Screen Shot 2021-04-22 at 21 09 43

@rebuilt
Copy link
Contributor

@rebuilt rebuilt commented Apr 22, 2021

That looks correct. Just as a sanity check, have you opened and closed the html file you're testing and are you typing the keybindings in insert mode?

@marcograhl
Copy link
Author

@marcograhl marcograhl commented Apr 22, 2021

Yes but its alright. I will tinker another day with this. Thank you for your time. Its not a must have feature its just a comfort coming from sublime

@rebuilt
Copy link
Contributor

@rebuilt rebuilt commented Apr 22, 2021

I think the issue might be me. I previously had the emmet plugin installed. I removed emmet from my configuration files but I did not run a clean to delete those folders. The keybindings were coming from my old emmet folder.

https://github.com/mattn/emmet-vim

@marcograhl
Copy link
Author

@marcograhl marcograhl commented Apr 22, 2021

I thought I maybe set it up with whichkey for fun... have a good one

@rebuilt
Copy link
Contributor

@rebuilt rebuilt commented Apr 23, 2021

I did end up setting up emmet-ls. I could not do it with compe.
The emmet-ls instructions use completion-nvim so that's what I used. It works very differently than the previous emmet plugin. To trigger the completion I press Tab+Tab+enter.

emmet

@marcograhl
Copy link
Author

@marcograhl marcograhl commented Apr 23, 2021

ok thats awesome, I deleted compe and installed completion-nvim (via PAcker )but nothing happens. Do I need to change the config in any way? and on the github they say you can use the . key to trigger completion with this setting:
let g:completion_trigger_character = ['.']
where would I put that in neovim. Thanks

@rebuilt
Copy link
Contributor

@rebuilt rebuilt commented Apr 23, 2021

Follow the setup docs to install completion
You don't need to set the completion trigger character
You do need these options

let g:completion_enable_snippet = 'vim-vsnip'

set completeopt=menuone,noinsert,noselect,preview
" Use <Tab> and <S-Tab> to navigate through popup menu
inoremap <expr> <Tab>   pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"

" Avoid showing message extra message when using completion
set shortmess+=c
imap <tab> <Plug>(completion_smart_tab)
imap <s-tab> <Plug>(completion_smart_s_tab)

This is a very important setting. It enables completion for every document. Otherwise you have to enable completion per language server. Read the docs if you prefer to enable with language server.

autocmd BufEnter * lua require'completion'.on_attach()

make sure you install the language server

npm install -g emmet-ls

Install vsnip and related snip support
https://github.com/hrsh7th/vim-vsnip
https://github.com/rafamadriz/friendly-snippets

use 'hrsh7th/vim-vsnip'
use 'hrsh7th/vim-vsnip-integ'
use 'rafamadriz/friendly-snippets'

If you want more snippets, get them here:
https://github.com/craigmac/vim-vsnip-snippets/tree/master/snippets
Read the vsnip docs to figure out how to install them.

There's a lot to set up and I didn't actually set it up on lunarvim. I modified my own configs which are still in vimscript syntax. But if you think it will help you out to look at my configs, they are here: https://github.com/rebuilt/neovim-config

I uploaded them just for you :)

@marcograhl
Copy link
Author

@marcograhl marcograhl commented Apr 23, 2021

wow, thats great Thank you. I will find some time next week to dive deep. Greetings from Germany and stay save

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants