-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4fa493e
commit 19e33a7
Showing
3 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
local M = {} | ||
|
||
--- Override the action map for the buffer when a language server attaches with a valid `root_dir` | ||
---@param lsp string The language server name | ||
---@param config spLauncher.Config The override configuration for 'workspace' mode to be merged in | ||
---@param bufnr? integer The buffer whose action map should be modified, defaults to `vim.api.nvim_get_current_buf()` | ||
function M.workspace(lsp, config, bufnr) | ||
vim.api.nvim_create_autocmd("LspAttach", { | ||
buffer = bufnr or vim.api.nvim_get_current_buf(), | ||
callback = function(args) | ||
local client = vim.lsp.get_client_by_id(args.data.client_id) | ||
|
||
if client and client.name == lsp and client.config.root_dir ~= nil and client.config.root_dir ~= "" then | ||
vim.b[args.buf].spLauncherActionMap = vim.tbl_deep_extend("force", vim.b[args.buf].spLauncherActionMap, config) | ||
end | ||
end, | ||
}) | ||
end | ||
|
||
return M |