forked from zml/zml
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.nvim.lua
More file actions
36 lines (32 loc) · 933 Bytes
/
Copy path.nvim.lua
File metadata and controls
36 lines (32 loc) · 933 Bytes
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
-- Get the current working directory (CWD)
local cwd = vim.fn.getcwd()
-- Load the local config file if it exists
local f, err = loadfile(".nvim.local.lua")
if not err then
f()
else
local capabilities = vim.lsp.protocol.make_client_capabilities()
-- Prepend CWD to relative paths
local zls_cmd = cwd .. "/../zml/tools/zls.sh"
vim.lsp.config["zls"] = {
capabilities = capabilities,
cmd = { zls_cmd },
root_marker = { "build.zig" },
filetypes = {"zig"},
}
vim.lsp.enable('zls')
vim.api.nvim_create_autocmd('BufWritePre',{
pattern = {"*.zig", "*.zon"},
callback = function(ev)
vim.lsp.buf.code_action({
context = { only = { "source.organizeImports" } },
apply = true,
})
vim.lsp.buf.code_action({
context = { only = { "source.fixAll" } },
apply = true,
})
vim.loop.sleep(100)
end
})
end