bmatcuk / stylelint-lsp

A stylelint Language Server
MIT License
48 stars 4 forks source link

Unable to get auto formatting in Neovim's built in LSP client #13

Closed gegoune closed 3 years ago

gegoune commented 3 years ago

Hi, I am trying to replace stylelint via efm-langserver after configuration for stylelint-lsp hs been merged to lspconfig (https://github.com/neovim/nvim-lspconfig/pull/800). I tried to set it up like:

require'lspconfig'.stylelint_lsp.setup{
   settings = {
       autoFixOnSave = true,
       autoFixOnFormat = true
   }
}

I do get code actions, diagnostics, but no automatic fixing. Is that expected to work? Does Neovim need to support it somehow? Did I misconfigure it perhaps? Any help greatly appreciated. Thanks!

bmatcuk commented 3 years ago

Unfortunately, I don't use nvim-lspconfig, so I'm not sure what the problem is. Reading through the documentation and such, perhaps the following change might work?:

require'lspconfig'.stylelint_lsp.setup{
   settings = {
       stylelintplus = {
           autoFixOnSave = true,
           autoFixOnFormat = true
       }
   }
}
gegoune commented 3 years ago

stylelintplus key did the job. I have tried stylelint, stylelint-lsp, stylelintlsp and config before as well as without that nested object at all. Did not think about stylelintplus at all. Thank you very much! Perhaps it could be mentioned in the docs?

bmatcuk commented 3 years ago

Yay, I'm glad that worked! I'll submit a PR to update lspconfig's docs. I originally wrote this as a language server for coc.nvim, which already had a stylelint plugin with far less features, so I needed a different name. Hence, stylelintplus 😆

gegoune commented 3 years ago

I used to use stylelintplus with coc, but it did not cross my mind that this lsp could be related. 😄

bmatcuk commented 3 years ago

If you don't mind me asking: what do you think of the built-in lsp support vs coc.nvim? Wondering if I should make the change, too =)

gegoune commented 3 years ago

I think if you are happy with coc stay with it. It's great piece of software. I managed to replicate all its functionality with other plugins and built-in lsp and I enjoyed the process. Learnt bit of lua and ended up almost completely rewriting my nvim configuration. It's been good transition but not without some problems which mostly are all solved now. I think there is something on lspconfig's wiki about coc too, might be worth having a look.

bmatcuk commented 3 years ago

Hmm, thanks for the review! Something to think about! =)