aboutsummaryrefslogtreecommitdiffstats
path: root/lua/lspconfig/configs/oxlint.lua
blob: 6246d72c3eeba6b2abfcb63f9c1a94a245d5dc48 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-- This config is DEPRECATED.
-- Use the configs in `lsp/` instead (requires Nvim 0.11).
--
-- ALL configs in `lua/lspconfig/configs/` will be DELETED.
-- They exist only to support Nvim 0.10 or older.
-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
local util = require 'lspconfig.util'

return {
  default_config = {
    cmd = { 'oxc_language_server' },
    filetypes = {
      'astro',
      'javascript',
      'javascriptreact',
      'svelte',
      'typescript',
      'typescript.tsx',
      'typescriptreact',
      'vue',
    },
    root_dir = util.root_pattern('.oxlintrc.json'),
    single_file_support = false,

    commands = {
      OxcFixAll = {
        function()
          local client = vim.lsp.get_clients({ bufnr = 0, name = 'oxlint' })[1]
          if client == nil then
            return
          end

          client.request('workspace/executeCommand', {
            command = 'oxc.fixAll',
            arguments = {
              {
                uri = vim.uri_from_bufnr(0),
              },
            },
          }, nil, 0)
        end,
        description = 'Apply fixes to current buffer using oxlint (--fix)',
      },
    },
  },
  docs = {
    description = [[
https://oxc.rs

A collection of JavaScript tools written in Rust.

```sh
npm install [-g] oxlint
```
]],
  },
}