bmatcuk / stylelint-lsp

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

filetypes setting apparently not respected #30

Closed bennypowers closed 2 years ago

bennypowers commented 2 years ago

Hello!

I've applied the following settings:

settings = {
    stylelintplus = {
      cssInJs = false,
      filetypes = { "css", "less", "scss", "sugarss", "vue", "wxss" }
    },
}

via lsp-installer, using this lua script:

https://github.com/bennypowers/dotfiles/blob/3f71e8f0b6e43f801435aeaab017322a088c6a44/.config/nvim/lua/config/lsp-installer.lua#L147

Expected

I Expected not to see linting errors in .js, .ts, or .cjs files

Actual

 Unknown word (CssSyntaxError) stylelintplus (CssSyntaxError) [2, 10]

Screen Shot 2022-02-15 at 9 27 18
bmatcuk commented 2 years ago

Hi @bennypowers. The file you linked doesn't appear to have any settings for stylelint-lsp, so I can't be certain what the problem is. However, the filetypes option is not part of stylelint-lsp's settings, but, rather, part of neovim's settings. See the default configuration here: https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/stylelint_lsp.lua

In other words, I think you'd need something like:

require'lspconfig'.stylelint_lsp.setup{
  filetypes = { ... },
  settings = {
    stylelintplus = {
      -- see available options in stylelint-lsp documentation
    }
  }
}

I personally don't use neovim's built-in lsp support, so I'm not 100% sure of that.

bennypowers commented 2 years ago

Indeed, I solved this by passing the entire options object, with filetype as a sibling for settings

https://github.com/bennypowers/dotfiles/blob/e085b302d6946b88a69465b23f8940c91375606c/.config/nvim/lua/config/lsp-installer.lua#L152-L167

bmatcuk commented 2 years ago

Awesome, glad to hear it!