{"id":13409706,"url":"https://github.com/creativenull/diagnosticls-configs-nvim","last_synced_at":"2025-04-15T11:07:24.716Z","repository":{"id":37989500,"uuid":"345505123","full_name":"creativenull/diagnosticls-configs-nvim","owner":"creativenull","description":"An unofficial collection of linters and formatters configured for diagnostic-languageserver for neovim.","archived":false,"fork":false,"pushed_at":"2025-04-10T13:24:47.000Z","size":178,"stargazers_count":90,"open_issues_count":1,"forks_count":8,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-15T11:07:03.346Z","etag":null,"topics":["checker","diagnostic-language-server","formatter","formatters","linter","linters","lua","neovim","nvim","nvim-lsp","nvim-plugin"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/creativenull.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":"supported-linters-and-formatters.md","governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-03-08T02:16:05.000Z","updated_at":"2025-04-10T13:24:22.000Z","dependencies_parsed_at":"2023-02-10T16:05:20.794Z","dependency_job_id":"c276aebd-9902-4cbf-bfbe-8b5d9696e1ca","html_url":"https://github.com/creativenull/diagnosticls-configs-nvim","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creativenull%2Fdiagnosticls-configs-nvim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creativenull%2Fdiagnosticls-configs-nvim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creativenull%2Fdiagnosticls-configs-nvim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creativenull%2Fdiagnosticls-configs-nvim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/creativenull","download_url":"https://codeload.github.com/creativenull/diagnosticls-configs-nvim/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249058370,"owners_count":21205910,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["checker","diagnostic-language-server","formatter","formatters","linter","linters","lua","neovim","nvim","nvim-lsp","nvim-plugin"],"created_at":"2024-07-30T20:01:02.908Z","updated_at":"2025-04-15T11:07:24.680Z","avatar_url":"https://github.com/creativenull.png","language":"Lua","funding_links":[],"categories":["LSP","Lua"],"sub_categories":["(requires Neovim 0.5)"],"readme":"# diagnosticls-configs-nvim\n\n\u003ca href=\"https://dotfyle.com/plugins/creativenull/diagnosticls-configs-nvim\"\u003e\n  \u003cimg src=\"https://dotfyle.com/plugins/creativenull/diagnosticls-configs-nvim/shield\"\n  alt=\"Configs on dotfyle\"\u003e\n\u003c/a\u003e\n\nAn unofficial collection of linter and formatter configurations for [diagnostic-languageserver][dls] to work with\nbuiltin [nvim-lsp][lsp]. Works only for Neovim \u003e= 0.5.\n\n## Supported linters and formatters\n\nCheck out [supported-linters-and-formatters.md](supported-linters-and-formatters.md)\n\n## Features\n\n+ Intelligently detect tools installed project-wide or system-wide - works only for node/npm, php/composer and\n  ruby/bundler, additional support for other build tools coming soon.\n+ Use `:checkhealth` to see any missing tools.\n+ Customize configs for your project needs.\n\n## Installation\n### Requirements\n\n+ [Neovim v0.5 and up][neovim] (Does not work work Vim as it does have a built-in lsp client)\n+ [nvim-lspconfig][lspconfig] plugin\n+ [Diagnostic Language Server][dls], globally installed: `npm i -g diagnostic-languageserver`\n\nYou will need to install `diagnostic-languageserver` and `nvim-lspconfig` before using this plugin.\n\n#### Packer.nvim\n\n```lua\nuse {\n    'creativenull/diagnosticls-configs-nvim',\n    tag = 'v0.1.8', -- `tag` is optional\n    requires = 'neovim/nvim-lspconfig',\n}\n```\n\n#### Vim-plug\n\n```vim\nPlug 'neovim/nvim-lspconfig'\nPlug 'creativenull/diagnosticls-configs-nvim', { 'tag': 'v0.1.8' } \" tag is optional\n```\n\n## Setup\n\nFirst you need to initialize the plugin, this is where you can pass your own LSP options:\n\n```lua\n-- Lua file\nlocal function on_attach(client)\n  print('Attached to ' .. client.name)\nend\n\nlocal dlsconfig = require 'diagnosticls-configs'\n\ndlsconfig.init {\n  -- Your custom attach function\n  on_attach = on_attach,\n}\n```\n\nFinally, setup the linters/formatters according to the filetype, here is an example for running eslint and prettier\nfor `javascript` and `javascriptreact` filetype:\n\n```lua\n-- Lua file\nlocal eslint = require 'diagnosticls-configs.linters.eslint'\nlocal standard = require 'diagnosticls-configs.linters.standard'\nlocal prettier = require 'diagnosticls-configs.formatters.prettier'\nlocal prettier_standard = require 'diagnosticls-configs.formatters.prettier_standard'\ndlsconfig.setup {\n  ['javascript'] = {\n    linter = eslint,\n    formatter = prettier\n  },\n  ['javascriptreact'] = {\n    -- Add multiple linters\n    linter = { eslint, standard },\n    -- Add multiple formatters\n    formatter = { prettier, prettier_standard }\n  }\n}\n```\n\n## Default configuration\n\nA default configuration for the supported filetypes is provided but not activated by default.\n\nTo activate the default configuration you can pass the `default_config` flag as true in the init function. Below are the\ndefault values for init:\n\n```lua\n-- Lua file\ndlsconfig.init {\n  -- Use a list of default configurations\n  -- set by this plugin\n  -- (Default: false)\n  default_config = false,\n\n  -- Set to false if formatting is not needed at all,\n  -- any formatter provided will be ignored\n  -- (Default: true)\n  format = true,\n}\n\ndlsconfig.setup()\n```\n\nYou will still need to call the `setup()` after `init()` for the changes to take effect. You can still pass your custom\nconfigurations to `setup()` as show in the [Setup section](#setup) and it will override any default configuration set\nby `default_config` if it's for the same filetype.\n\nNOTE: For `format` option it does not imply that it will \"format on save\". You still need to setup that in your lsp\non_attach handler.\n\n## Advanced Configuration\n\nIf default configurations of a linter/formatter do not work for your use-case, or there are additional configuration\nthat needs to be added which is not provided by default. Then you can extend the built-in configurations with your own\nmodifications. The API is the same as [diagnostic-languageserver Initialization Options][dls-setup] on linter/formatter\nstructure. You can use `vim.tbl_extend()` to extend these tables:\n\n```lua\n-- Lua file\nlocal eslint = require 'diagnosticls-configs.linter.eslint'\n\n-- ESLint Extented Config\neslint = vim.tbl_extend('force', eslint, {\n\n  -- REQUIRED: if `default_config` is enabled, separate name from original sourceName\n  sourceName = 'eslint_extended',\n\n  args = { 'extra', 'args' },\n  rootPatterns = { '.git' }\n})\n\ndlsconfig.setup {\n  javascript = {\n    linter = eslint\n  }\n}\n```\n\nNOTE: If you have [`default_config` enabled](#default-configuration), then `sourceName` needs to be a different name\nto the provided name, you can just add `_extended` or any other unique name to the extended configuration will work.\nThis is because other defaults might use the same linter of the same `sourceName` and would default to use\nthat instead of your own extended configuration.\n\n# TODO\n\n+ [X] Tests with busted/vusted or plenary - using plenary test_harness\n+ [X] Use `:checkhealth` to display status of linters/formatters registered with plugin\n+ [X] Add ability to override args, root patterns, etc\n+ [X] Add vim docs\n+ [X] Add contributing content\n+ [X] Add feature to allow multiple linters/formatters: [see ref](https://github.com/iamcco/diagnostic-languageserver#config--document)\n\n## Contributing\n\nFirst of all, thank you for your contribution 🙂!\n\nTo help create configurations start with the [diagnostic-languageserver API][dls-setup] to know how the object is\nstructured for a linter or a formatter. Also [check out the wiki][dls-wiki] to see some examples. Finally, check out the\nconfigurations created in the `lua/diagnosticls-configs/linters` and `lua/diagnosticls-configs/formatters` and see how\nthey are implemented.\n\nTools required for linting and formatting for this project (which are also supported by this plugin):\n+ [`luacheck`][luacheck] - Linting\n+ [`stylua`][stylua] - Formatting\n\nFor testing, add the relevant test logic in `tests/diagnosticls-configs` and then run:\n\n```sh\nmake test\n```\n\n## Credits\n\nCredits goes to the following repos for inspiration:\n\n+ [Diagnostic Language Server](https://github.com/iamcco/diagnostic-languageserver) - for example configs in json format\n+ [ale](https://github.com/dense-analysis/ale) - for a vibrate list of supported linters/formatters to look through and implement\n\n[dls]: https://github.com/iamcco/diagnostic-languageserver\n[dls-setup]: https://github.com/iamcco/diagnostic-languageserver#config--document\n[dls-wiki]: https://github.com/iamcco/diagnostic-languageserver/wiki\n[lsp]: https://neovim.io/doc/user/lsp.html\n[packer]: https://github.com/wbthomason/packer.nvim\n[luacheck]: https://github.com/mpeterv/luacheck\n[stylua]: https://github.com/JohnnyMorganz/StyLua\n[lspconfig]: https://github.com/neovim/nvim-lspconfig\n[neovim]: https://github.com/neovim/neovim\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcreativenull%2Fdiagnosticls-configs-nvim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcreativenull%2Fdiagnosticls-configs-nvim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcreativenull%2Fdiagnosticls-configs-nvim/lists"}