-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Default language server settings for TypeScript/Eslint/Prettier #7079
Comments
Side note: Using [[language]]
name = "javascript"
formatter = { command = 'prettier', args = ["--parser", "typescript"] }
# auto-format = true However, since formatters are an opinionated matter, you would hardly see built-in defaults for that. Users will always need to configure formatters in their An idea to add some day might be config presets, e.g. packaged configuration which enables prettier for all languages it supports. this feature would be independent of #2507, though. I believe prettier has no language server capabilities. TypeScript language server already has default configuration: https://github.com/helix-editor/helix/blob/master/languages.toml#L117-L138 |
Hmm in that case the least we should do is add a working example for this to the documentation, since those 3 are the staple for JS/TS work. |
Yeah that makes sense I think, though I'm not sure how that would look like in practice... But it certainly makes sense to add some ready-to-copy-paste examples in the wiki for common configurations like eslint + + tsserver. FWIW this is what I'm using for eslint currently (maybe I'll add this in the wiki at some time, if no-one else does in the meantime): [language-server.eslint]
args = ["--stdio"]
command = "vscode-eslint-language-server"
[language-server.eslint.config]
format = true
nodePath = ""
onIgnoredFiles = "off"
packageManager = "yarn"
quiet = false
rulesCustomizations = []
run = "onType"
useESLintClass = false
validate = "on"
codeAction = { disableRuleComment = { enable = true, location = "separateLine" }, showDocumentation = { enable = true } }
codeActionOnSave = { mode = "all" }
experimental = { }
problems = { shortenToSingleLine = false }
workingDirectory = { mode = "auto" } I'm using prettier via [language-server.efm-lsp-prettier]
command = "efm-langserver"
[language-server.efm-lsp-prettier.config]
documentFormatting = true
[language-server.efm-lsp-prettier.config.languages]
[[language-server.efm-lsp-prettier.config.languages.javascript]]
formatCommand = "prettier --stdin-filepath ${INPUT}"
formatStdin = true
[[language-server.efm-lsp-prettier.config.languages.javascriptreact]]
formatCommand = "prettier --stdin-filepath ${INPUT}"
formatStdin = true
[[language-server.efm-lsp-prettier.config.languages.json]]
formatCommand = "prettier --stdin-filepath ${INPUT}"
formatStdin = true
#... Not sure if there's a semantical difference to using it via the Here's a project with eslint + eslint-prettier enforced rules, that's working well with the above config: https://github.com/Philipp-M/tree-sitter-yuck/ Might be of interest for some. |
@Philipp-M been reading up your comments about eslint integration and the docs on master so appreciate the great work! I'm wondering if it's possible to use eslint with prettier plugins, more specifically use eslint to fix the linting issues along with formatting. I do see eslint errors when I write code that doesn't fit my prettier config, but I can't fix it using the format command. Config files that I've been using: .eslintrc.cjsmodule.exports = {
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:prettier/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': 'warn',
},
ignorePatterns: ['.eslintrc.cjs'],
} languages.toml...
# the above part is similar to yours
[[language]]
name = "typescript"
language-servers = [ { name = "eslint" , except-features = [ "format" ] }, "efm-lsp-prettier" ]
[[language]]
name = "tsx"
language-servers = [ { name = "eslint" , except-features = [ "format" ] }, "efm-lsp-prettier" ]
|
Hey gang, is there any progress here? I'm trying to get I'm trying to use
Here's the #####
#
# efm-lsp-eslint
#
#####
[language-server.efm-lsp-eslint]
command = "efm-langserver"
[language-server.efm-lsp-eslint.config]
documentFormatting = true
[[language-server.efm-lsp-prettier.config.languages.javascript]]
formatCommand ="eslint --stdin-filename ${INPUT}"
formatStdin = true
[[language-server.efm-lsp-prettier.config.languages.react]]
formatCommand ="eslint --stdin-filename ${INPUT}"
formatStdin = true
[[language-server.efm-lsp-prettier.config.languages.typescript]]
formatCommand ="eslint --stdin-filename ${INPUT}"
formatStdin = true
[[language-server.efm-lsp-prettier.config.languages.typescriptreact]]
formatCommand ="eslint --stdin-filename ${INPUT}"
formatStdin = true
[[language-server.efm-lsp-prettier.config.languages.css]]
formatCommand ="eslint --stdin-filename ${INPUT}"
formatStdin = true
[[language-server.efm-lsp-prettier.config.languages.scss]]
formatCommand ="eslint --stdin-filename ${INPUT}"
formatStdin = true
[[language-server.efm-lsp-prettier.config.languages.html]]
formatCommand ="eslint --stdin-filename ${INPUT}"
formatStdin = true
#####
#
# efm-lsp-prettier
#
#####
[language-server.efm-lsp-prettier]
command = "efm-langserver"
[language-server.efm-lsp-prettier.config]
documentFormatting = true
[[language-server.efm-lsp-prettier.config.languages.javascript]]
formatCommand ="prettierd --stdin-filepath ${INPUT}"
formatStdin = true
[[language-server.efm-lsp-prettier.config.languages.react]]
formatCommand ="prettierd --stdin-filepath ${INPUT}"
formatStdin = true
[[language-server.efm-lsp-prettier.config.languages.typescript]]
formatCommand ="prettierd --stdin-filepath ${INPUT}"
formatStdin = true
[[language-server.efm-lsp-prettier.config.languages.typescriptreact]]
formatCommand ="prettierd --stdin-filepath ${INPUT}"
formatStdin = true
[[language-server.efm-lsp-prettier.config.languages.css]]
formatCommand ="prettierd --stdin-filepath ${INPUT}"
formatStdin = true
[[language-server.efm-lsp-prettier.config.languages.scss]]
formatCommand ="prettierd --stdin-filepath ${INPUT}"
formatStdin = true
[[language-server.efm-lsp-prettier.config.languages.html]]
formatCommand ="prettierd --stdin-filepath ${INPUT}"
formatStdin = true
#####
#
# languages
#
#####
[[language]]
name = "javascript"
auto-format = true
language-servers = [
{ name = "efm-lsp-prettier", only-features = [ "format" ] },
{ name = "efm-lsp-eslint", only-features = [ "format" ] },
{ name = "typescript-language-server", except-features = [ "format" ] }
]
[[language]]
name = "jsx"
auto-format = true
language-servers = [
{ name = "efm-lsp-prettier", only-features = [ "format" ] },
{ name = "efm-lsp-eslint", only-features = [ "format" ] },
{ name = "typescript-language-server", except-features = [ "format" ] }
]
[[language]]
name = "typescript"
auto-format = true
language-servers = [
{ name = "efm-lsp-prettier", only-features = [ "format" ] },
{ name = "efm-lsp-eslint", only-features = [ "format" ] },
{ name = "typescript-language-server", except-features = [ "format" ] }
]
[[language]]
name = "tsx"
auto-format = true
language-servers = [
{ name = "efm-lsp-prettier", only-features = [ "format" ] },
{ name = "efm-lsp-eslint", only-features = [ "format" ] },
{ name = "typescript-language-server", except-features = [ "format" ] }
]
[[language]]
name = "css"
auto-format = true
language-servers = [
{ name = "efm-lsp-prettier", only-features = [ "format" ] },
{ name = "vscode-css-language-server", except-features = [ "format" ] }
]
[[language]]
name = "scss"
auto-format = true
language-servers = [
{ name = "efm-lsp-prettier", only-features = [ "format" ] },
{ name = "vscode-css-language-server", except-features = [ "format" ] }
]
[[language]]
name = "html"
auto-format = true
language-servers = [
{ name = "efm-lsp-prettier", only-features = [ "format" ] },
{ name = "vscode-css-language-server", except-features = [ "format" ] }
] But I can't seem to figure out what's going wrong. Happy to help provide debugging information. |
You probably don't want to use efm-langserver at least for eslint. There were a few configurations regarding eslint (e.g. in my other comment here). |
Can you tell us the source of these config options? Thanks. |
Mostly from neovims lsp-config, but I've also digged a little bit in the source code of the vscode-eslint-language-server itself. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
First of all, thank you for all involved, especially @Philipp-M for getting #2507 merged. Epic.
Since the multiple language servers are now implemented, we can work with TypeScript/Eslint/Prettier. We do need some config to set it up though.
In the thread of #2507 it was discussed to add some sane defaults to make it work out of the box.
There have been some configs posted in the PR, but do we already have a consensus of what's the best way to set it up?
The text was updated successfully, but these errors were encountered: