Browse Source
This adds wrapping of lsp for one language: lua. It adds two modules, `auto_install` and `lua`. The former toggles auto installation, and is sort of a marker module. Beyond installing and configuring nvim-lsp-installer and DAPInstall.nvim, it doesn't really do anything. It's purpose is to be checked on the lua module which will use the installers if it is enabled. Otherwise just falls back to $PATH. Since I'm on NixOS, I can only test the non-auto installation, but it seems to be downloading properly for the auto version. The lua module also installs additional packages, namely lua-dev.nvim, which used to be part of the lsp module. It could add keybinds, but I couldn't think of any. It has a special autocommand that `dofile`s the config.lua, which actually sets up lsp (and possibly dap) lazily and only after the first lua file is opened. This commit is meant as a template/prototype to other language wrappings.my-config
Luigi Sartor Piucco
3 years ago
6 changed files with 137 additions and 0 deletions
@ -0,0 +1,23 @@ |
|||
local auto_install = {} |
|||
|
|||
auto_install.defaults = { |
|||
lsp_dir = vim.fn.stdpath("data") .. "/lsp-install/", |
|||
dap_dir = vim.fn.stdpath("data") .. "/dap-install/", |
|||
treesitter_dir = vim.fn.stdpath("data") .. "/treesitter-install/", |
|||
} |
|||
|
|||
auto_install.packer_config = {} |
|||
auto_install.packer_config["nvim-lsp-installer"] = function() |
|||
local lsp_installer = require("nvim-lsp-installer") |
|||
lsp_installer.settings({ |
|||
install_root_dir = doom.auto_install.lsp_dir, |
|||
}) |
|||
end |
|||
auto_install.packer_config["DAPInstall.nvim"] = function() |
|||
local dap_install = require("dap-install") |
|||
dap_install.setup({ |
|||
installation_path = doom.auto_install.dap_dir, |
|||
}) |
|||
end |
|||
|
|||
return auto_install |
@ -0,0 +1,19 @@ |
|||
return { |
|||
["DAPInstall.nvim"] = { |
|||
"Pocco81/DAPInstall.nvim", |
|||
commit = "dd09e9dd3a6e29f02ac171515b8a089fb82bb425", |
|||
after = "nvim-dap", |
|||
cmd = { |
|||
"DIInstall", |
|||
"DIList", |
|||
"DIUninstall", |
|||
}, |
|||
module = "dap-install", |
|||
}, |
|||
["nvim-lsp-installer"] = { |
|||
"williamboman/nvim-lsp-installer", |
|||
commit = "bcce5db53b966e2dbd97fc8d1bbfa7db4a405f13", |
|||
opt = true, |
|||
module = "nvim-lsp-install", |
|||
}, |
|||
} |
@ -0,0 +1,5 @@ |
|||
local autocmds = { |
|||
{ "BufNewFile,BufRead", "*.lua", "++once", [[lua dofile(vim.api.nvim_get_runtime_file("*/doom/modules/lua/config.lua", false)[1])]] } |
|||
} |
|||
|
|||
return autocmds |
@ -0,0 +1,49 @@ |
|||
local utils = require("doom.utils") |
|||
local is_plugin_disabled = utils.is_plugin_disabled |
|||
local lspconfig = require("lspconfig") |
|||
|
|||
local runtime_path = vim.split(package.path, ';') |
|||
table.insert(runtime_path, "lua/?.lua") |
|||
table.insert(runtime_path, "lua/?/init.lua") |
|||
|
|||
local config = vim.tbl_deep_extend( |
|||
"force", |
|||
doom.lua, |
|||
{ |
|||
settings = { |
|||
Lua = { |
|||
runtime = { |
|||
path = runtime_path, |
|||
}, |
|||
}, |
|||
}, |
|||
capabilities = utils.get_capabilities(), |
|||
on_attach = function(client) |
|||
if not is_plugin_disabled("illuminate") then |
|||
utils.illuminate_attach(client) |
|||
end |
|||
if type(doom.lua.on_attach) == "function" then |
|||
doom.lua.on_attach(client) |
|||
end |
|||
end, |
|||
} |
|||
) |
|||
|
|||
if not is_plugin_disabled("auto_install") then |
|||
local lsp_installer = require("nvim-lsp-installer.servers") |
|||
local server_available,server = lsp_installer.get_server("sumneko_lua") |
|||
if server_available then |
|||
config.cmd = { lsp_installer.get_server_install_path("sumneko_lua") .. "/extension/server/bin/lua-language-server" } |
|||
if not server:is_installed() then |
|||
vim.defer_fn(function() |
|||
server:install() |
|||
end, 50) |
|||
end |
|||
end |
|||
end |
|||
|
|||
lspconfig.sumneko_lua.setup(config) |
|||
|
|||
vim.defer_fn(function() |
|||
require("nvim-treesitter.install").update()("lua") |
|||
end, 0) |
@ -0,0 +1,34 @@ |
|||
local lua = {} |
|||
|
|||
lua.defaults = { |
|||
settings = { |
|||
Lua = { |
|||
runtime = { |
|||
version = "LuaJIT", |
|||
}, |
|||
diagnostics = { |
|||
globals = { "vim", "doom" }, |
|||
}, |
|||
workspace = { |
|||
library = vim.api.nvim_get_runtime_file("", true), |
|||
}, |
|||
telemetry = { |
|||
enable = false, |
|||
}, |
|||
}, |
|||
}, |
|||
dev = { |
|||
library = { |
|||
vimruntime = true, |
|||
types = true, |
|||
plugins = true, |
|||
}, |
|||
}, |
|||
} |
|||
|
|||
lua.packer_config = {} |
|||
lua.packer_config["lua-dev.nvim"] = function () |
|||
require("lua-dev").setup(doom.lua.dev) |
|||
end |
|||
|
|||
return lua |
@ -0,0 +1,7 @@ |
|||
return { |
|||
["lua-dev.nvim"] = { |
|||
"folke/lua-dev.nvim", |
|||
commit = "6a7abb62af1b6a4411a3f5ea5cf0cb6b47878cc0", |
|||
ft = "lua", |
|||
}, |
|||
} |
Loading…
Reference in new issue