LuaLS / lua-language-server

A language server that offers Lua language support - programmed in Lua
https://luals.github.io
MIT License
3.35k stars 318 forks source link

Setting up `codestyle-check` precisely? #2100

Open msva opened 1 year ago

msva commented 1 year ago

Hi there!

Is there any way to set up (disable) exact checks for codestyle-check? .stylua.toml and .editorconfig syntax doesn't have much parameters, and doesn't cover such usecases like "spaces before single argument".

For example, when I type local a = require"foo".moo, and I don't want that codestyle checker triggered on missing space (or anything) here, and I want this "globally" (to don't place comments ---@diagnostic comments here and there and everywhere everytime).

Or, say, I have function, that takes a table as argument, and place table global in metadate, to allow OOP-like calls on tables.

So, as syntactig sugar I have variable T set to this function. So, I'm initializing tables with local mytable = T{}.

And I don't want that codestyle-checker blame on missing space here too.

And so on...

So, it would be nice, if there was a possibility to configure (enable/disable) exact checks per-project and globally (default settings, that per-project ones would override).

And I digged all around lua_ls and emmylua docs and didn't find a way to do that.

Can you advice me, please?

CppCXY commented 1 year ago

the code-style check is based on the formatting target of emmylua-codestyle, If you're not using lua-ls formatting, you'd better turn it off. or add space_before_function_call_single_arg = none to .editorconfig

msva commented 1 year ago

I tried followinf setup, but that didn't help for any of mentioned cases :shrug:

format = {
  enable = true,
  defaultConfig = {
    space_before_attribute = false,
    space_before_function_call_single_arg = false,
  },
},

Although, I didn't try to add that parameters to .editorconfig. Will check it. And will it work if I'll put another emmylua formattinng directives to .editorconfig?

CppCXY commented 1 year ago

add it to editorconfig, when a editorconfig file exists, only its configuration is valid