From 1d1a3539c8e9b1b4751a1a9f1724c0b976eeacd1 Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Sun, 27 Oct 2024 20:21:33 +0530 Subject: [PATCH] nvim: Enable LSP for zig --- nvim/.config/nvim/after/ftplugin/zig.lua | 4 ++++ nvim/.config/nvim/lua/lsp-utils.lua | 14 ++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 nvim/.config/nvim/after/ftplugin/zig.lua diff --git a/nvim/.config/nvim/after/ftplugin/zig.lua b/nvim/.config/nvim/after/ftplugin/zig.lua new file mode 100644 index 0000000..24a2201 --- /dev/null +++ b/nvim/.config/nvim/after/ftplugin/zig.lua @@ -0,0 +1,4 @@ +local lsp_utils = require('lsp-utils') +local zls_config = lsp_utils.zls_config() + +vim.lsp.start(zls_config) diff --git a/nvim/.config/nvim/lua/lsp-utils.lua b/nvim/.config/nvim/lua/lsp-utils.lua index 1681f07..d5da917 100644 --- a/nvim/.config/nvim/lua/lsp-utils.lua +++ b/nvim/.config/nvim/lua/lsp-utils.lua @@ -372,4 +372,18 @@ function M.typescript_config() end end +function M.zls_config() + local root_files = { 'zls.json', 'build.zig' } + local root_directory = get_root_directory(root_files) + + return { + name = "zls", + cmd = { "zls" }, + capabilities = default_capabilities, + root_dir = root_directory, + filetypes = { 'zig', 'zir' }, + single_file_support = true, + } +end + return M