Skip to content

Commit

Permalink
Implement setIpkg LSP command; Add config option to run the LSP serve…
Browse files Browse the repository at this point in the history
…r configured with a specified ipkg file
  • Loading branch information
Russoul committed Nov 27, 2024
1 parent 8bff029 commit 1ab43fd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lua/idris2/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ end

local function setup_lsp()
local root_dir_error = function(startpath)

-- If ipkg file is specified in the user config, assume default startpath
if config.options.ipkg then
return startpath
end

local path = nvim_lsp.util.root_pattern("*.ipkg")(startpath)
if path ~= nil then
return path
Expand All @@ -57,7 +63,17 @@ local function setup_lsp()
vim.log.levels.WARN
)
end
local server = vim.tbl_deep_extend("force", config.options.server, { root_dir = root_dir_error })

-- If ipkg file is specified in user config, pass it down to lspconfig as idris2-lsp command argument
local cmd
if config.options.ipkg
then
cmd = { "idris2-lsp", config.options.ipkg }
else
cmd = { "idris2-lsp" }
end

local server = vim.tbl_deep_extend("force", config.options.server, { cmd = cmd, root_dir = root_dir_error })
nvim_lsp.idris2_lsp.setup(server)

-- Goto... commands may jump to non package-local files, e.g. base or contrib
Expand Down
8 changes: 8 additions & 0 deletions lua/idris2/set_ipkg.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
local M = {}

-- Send "setIpkg" command to LSP
function M.send(ipkg)
vim.lsp.buf_request(0, 'workspace/executeCommand', {command = "setIpkg", arguments = {ipkg}}, function() end)
end

return M

0 comments on commit 1ab43fd

Please sign in to comment.