-
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathtools.lua
More file actions
59 lines (48 loc) · 1.69 KB
/
tools.lua
File metadata and controls
59 lines (48 loc) · 1.69 KB
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
59
---@alias ft string -- filetype
---Abstract class for efm tools
---@class EfmToolConfig
---@field requireMarker? boolean
---@field rootMarkers? string[]
---Return type for a tool's efm function that is a formatter
---@class EfmFormatter: EfmToolConfig
---@field formatCommand string -- executable and args
---@field formatCanRange? boolean
---@field formatStdIn? boolean
---Return type for a tool's efm function that is a linter
---@class EfmLinter: EfmToolConfig
---@field lintCommand string -- executable and args
---@field lintSource? 'efm' | 'efmls' -- displays above float
---@field lintStdIn? boolean
---@field prefix? string
---@class Tool
---@field name string -- tool or lspconfig name
---@field runner? 'lspconfig'
---@field fts? ft[] -- for efm, list of filetypes to register
---@field efm? fun(): EfmFormatter|EfmLinter
---@field skip_init? boolean -- e.g. for ts_ls, we use typescript-tools.nvim to init and not raw lspconfig
---@alias ToolGroup table<string, boolean>
---@alias ToolGroups table<string, ToolGroup>
local M = {}
---@type string[]
M.standalone_lsp_names = {}
--- This is the Tool config that has a .efm() method, not the result of calling
--- the efm() method itself. We cannot call until plugins loaded.
---@type table<ft, Tool[]>
M.config_with_efm_by_ft = {}
--- Process the tool definition
---@param config Tool
M.register = function(config)
if config.fts and config.efm then
vim.iter(config.fts):each(function(ft)
M.config_with_efm_by_ft[ft] = require("dko.utils.table").append(
M.config_with_efm_by_ft[ft],
config
)
end)
return
end
if config.runner == 'lspconfig' then
table.insert(M.standalone_lsp_names, config.name)
end
end
return M