-
Notifications
You must be signed in to change notification settings - Fork 4
LSP initialisation abstraction #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3c2a4db
5215c59
ed36131
11a61f8
7b354ff
667ddb3
29c6524
7148804
12546a1
5cf95c1
892f356
b66ce77
2e8aa4d
3628242
322085e
e8960c4
2b123b0
88de2bb
f755fb2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,6 @@ | ||
| local helpers = require("nobbz.lsp.helpers") | ||
|
|
||
| require("lspconfig").astro.setup({ | ||
| on_attach = helpers.keymap, | ||
| capabilities = LSP_CAPAS, | ||
| }) | ||
|
|
||
| require("nobbz.health").register_lsp("astro") | ||
| return { | ||
| name = "astro", | ||
| on_attach = { helpers.keymap, }, | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,7 @@ | ||
| local helpers = require("nobbz.lsp.helpers") | ||
|
|
||
| require("lspconfig").clangd.setup({ | ||
| on_attach = helpers.keymap, | ||
| capabilities = LSP_CAPAS, | ||
| return { | ||
| name = "clangd", | ||
| on_attach = { helpers.keymap, }, | ||
| cmd = { "clangd", "--background-index", }, | ||
| }) | ||
|
|
||
| require("nobbz.health").register_lsp("clangd") | ||
| } | ||
NobbZ marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,6 @@ | ||
| local helpers = require("nobbz.lsp.helpers") | ||
|
|
||
| require("lspconfig").digestif.setup({ | ||
| on_attach = helpers.keymap, | ||
| capabilities = LSP_CAPAS, | ||
| }) | ||
|
|
||
| require("nobbz.health").register_lsp("digestif") | ||
| return { | ||
| name = "digestif", | ||
| on_attach = { helpers.keymap, }, | ||
| } | ||
NobbZ marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,7 @@ | ||
| local helpers = require("nobbz.lsp.helpers") | ||
|
|
||
| require("lspconfig").elixirls.setup({ | ||
| on_attach = helpers.keymap, | ||
| capabilities = LSP_CAPAS, | ||
| return { | ||
| name = "elixirls", | ||
| on_attach = { helpers.keymap, }, | ||
| cmd = { "elixir-ls", }, | ||
| }) | ||
|
|
||
| require("nobbz.health").register_lsp("elixirls") | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,6 @@ | ||
| local helpers = require("nobbz.lsp.helpers") | ||
|
|
||
| require("lspconfig").gleam.setup({ | ||
| on_attach = helpers.keymap, | ||
| capabilities = LSP_CAPAS, | ||
| }) | ||
|
|
||
| require("nobbz.health").register_lsp("gleam") | ||
| return { | ||
| name = "gleam", | ||
| on_attach = { helpers.keymap, }, | ||
| } | ||
NobbZ marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,6 @@ | ||
| local helpers = require("nobbz.lsp.helpers") | ||
|
|
||
| require("lspconfig").html.setup({ | ||
| on_attach = helpers.keymap, | ||
| capabilities = LSP_CAPAS, | ||
| }) | ||
|
|
||
| require("nobbz.health").register_lsp("html") | ||
| return { | ||
| name = "html", | ||
| on_attach = { helpers.keymap, }, | ||
| } | ||
NobbZ marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,52 +1,50 @@ | ||
| local helpers = require("nobbz.lsp.helpers") | ||
|
|
||
| require("lspconfig").lua_ls.setup({ | ||
| on_attach = helpers.combine({ | ||
| helpers.default, | ||
| function(_, buffer) | ||
| vim.api.nvim_create_autocmd("BufWritePre", { | ||
| buffer = buffer, | ||
| callback = function() | ||
| vim.lsp.buf.format({ | ||
| async = false, | ||
| bufnr = buffer, | ||
| }) | ||
| end, | ||
| local function on_attach(_, buffer) | ||
| vim.api.nvim_create_autocmd("BufWritePre", { | ||
| buffer = buffer, | ||
| callback = function() | ||
| vim.lsp.buf.format({ | ||
| async = false, | ||
| bufnr = buffer, | ||
| }) | ||
| end, | ||
| }), | ||
| }) | ||
| end | ||
|
|
||
| -- this snippet is adopted from: | ||
| -- https://github.com/neovim/nvim-lspconfig/blob/37f362ef42d1a604d332e8d3d7d47593852b4313/doc/server_configurations.md#lua_ls | ||
| on_init = function(client) | ||
| local path = client.workspace_folders[1].name | ||
| -- this snippet is adopted from: | ||
| -- https://github.com/neovim/nvim-lspconfig/blob/37f362ef42d1a604d332e8d3d7d47593852b4313/doc/server_configurations.md#lua_ls | ||
| local function on_init(client) | ||
| local path = client.workspace_folders[1].name | ||
|
|
||
| -- Search in project for a `.luarc.json` or `.luarc.jsonc`, do nothing if found. | ||
| local luarc_json_exists = vim.fn.glob(path .. "/.luarc.json") ~= "" | ||
| local luarc_jsonc_exists = vim.fn.glob(path .. "/.luarc.jsonc") ~= "" | ||
| if luarc_json_exists or luarc_jsonc_exists then return end | ||
| -- Search in project for a `.luarc.json` or `.luarc.jsonc`, do nothing if found. | ||
| local luarc_json_exists = vim.fn.glob(path .. "/.luarc.json") ~= "" | ||
| local luarc_jsonc_exists = vim.fn.glob(path .. "/.luarc.jsonc") ~= "" | ||
| if luarc_json_exists or luarc_jsonc_exists then return end | ||
|
|
||
| -- if there is a luarc.lua in the workspace root, import and merge. | ||
| local plugin_paths = vim.split(vim.fn.glob(path .. "/plugins/*/lua"), "\n", { trimempty = true, }) | ||
| plugin_paths = vim.iter(plugin_paths):map(function(plugin_path) return string.sub(plugin_path, -1, -4) end) | ||
| table.insert(plugin_paths, vim.env.VIMRUNTIME) | ||
| -- if there is a luarc.lua in the workspace root, import and merge. | ||
| local plugin_paths = vim.split(vim.fn.glob(path .. "/plugins/*/lua"), "\n", { trimempty = true, }) | ||
| plugin_paths = vim.iter(plugin_paths):map(function(plugin_path) return string.sub(plugin_path, -1, -4) end) | ||
| table.insert(plugin_paths, vim.env.VIMRUNTIME) | ||
NobbZ marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| -- Assume we are in a nvim config and configure appropriately to not warn on nvim globals | ||
| client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, { | ||
| runtime = { version = "LuaJIT", }, | ||
| -- Make the server aware of Neovim runtime files | ||
| workspace = { | ||
| checkThirdParty = false, | ||
| library = plugin_paths, | ||
| }, | ||
| }) | ||
| end, | ||
| -- Assume we are in a nvim config and configure appropriately to not warn on nvim globals | ||
| client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, { | ||
| runtime = { version = "LuaJIT", }, | ||
| -- Make the server aware of Neovim runtime files | ||
| workspace = { | ||
| checkThirdParty = false, | ||
| library = plugin_paths, | ||
| }, | ||
| }) | ||
| end | ||
|
|
||
| return { | ||
| name = "lua_ls", | ||
| on_attach = { helpers.default, on_attach, }, | ||
| on_init = on_init, | ||
| settings = { | ||
| Lua = { | ||
| hint = { enable = true, }, | ||
| }, | ||
| }, | ||
| capabilities = LSP_CAPAS, | ||
| }) | ||
|
|
||
| require("nobbz.health").register_lsp("lua_ls") | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,9 +6,7 @@ vim.filetype.add({ | |
| }, | ||
| }) | ||
|
|
||
| require("lspconfig").mdx_analyzer.setup({ | ||
| on_attach = helpers.keymap, | ||
| capabilities = LSP_CAPAS, | ||
| }) | ||
|
|
||
| require("nobbz.health").register_lsp("mdx_analyzer") | ||
| return { | ||
| name = "mdx_analyzer", | ||
| on_attach = { helpers.keymap, }, | ||
| } | ||
|
Comment on lines
+9
to
+12
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Missing lazyloading mechanism as required by coding guidelines. The declarative configuration approach is consistent with the refactoring pattern. However, the coding guidelines specify that plugins should be lazyloaded through 🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,7 @@ | ||
| local helpers = require("nobbz.lsp.helpers") | ||
|
|
||
| require("lspconfig").mesonlsp.setup({ | ||
| on_attach = helpers.keymap, | ||
| capabilities = LSP_CAPAS, | ||
| return { | ||
| name = "mesonlsp", | ||
| on_attach = { helpers.keymap, }, | ||
| root_dir = require("lspconfig.util").root_pattern(".git"), | ||
| }) | ||
|
|
||
| require("nobbz.health").register_lsp("mesonlsp") | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,8 @@ | ||
| local helpers = require("nobbz.lsp.helpers") | ||
|
|
||
| require("lspconfig").nushell.setup({ | ||
| on_attach = helpers.default, | ||
| capabilities = LSP_CAPAS, | ||
| return { | ||
| name = "nushell", | ||
| on_attach = { helpers.default, }, | ||
| filetypes = { "nu", }, | ||
| cmd = { "nu", "--lsp", }, | ||
| }) | ||
|
|
||
| require("nobbz.health").register_lsp("nushell") | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.