This repository has been archived by the owner on Apr 16, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 107
/
init.lua
60 lines (53 loc) · 1.45 KB
/
init.lua
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
60
local linter = {}
linter.settings = {
format_on_save = false,
null_ls_settings = {
default_timeout = 2000,
diagnostics_format = "#{m} (#{s})",
},
}
linter.requires_modules = { "features.lsp" }
linter.packages = {
["null-ls.nvim"] = {
"jose-elias-alvarez/null-ls.nvim",
dependencies={"neovim/nvim-lspconfig"},
lazy = true,
},
}
linter.configs = {}
linter.configs["null-ls.nvim"] = function()
local null_ls = require("null-ls")
local null_ls_settings = doom.features.linter.settings.null_ls_settings
null_ls.setup(vim.tbl_deep_extend("force", null_ls_settings, {
on_attach = function(client)
if
client.server_capabilities.documentFormattingProvider
and doom.features.linter.settings.format_on_save
then
vim.cmd([[
augroup LspFormatting
autocmd! * <buffer>
autocmd BufWritePre <buffer> lua type(vim.lsp.buf.format) == "function" and vim.lsp.buf.format() or vim.lsp.buf.formatting_sync()
augroup END
]])
end
end,
}))
end
linter.binds = {
{
"<leader>cf",
function()
local null_ls_settings = doom.features.linter.settings.null_ls_settings
if type(vim.lsp.buf.format) == "function" then
vim.lsp.buf.format({
timeout_ms = null_ls_settings.default_timeout,
})
else
vim.lsp.buf.formatting_sync(nil, null_ls_settings.default_timeout)
end
end,
name = "Format/Fix",
},
}
return linter