mirror of
https://github.com/kristoferssolo/telescope-frecency.nvim.git
synced 2025-10-21 20:10:38 +00:00
fix: fetch lsp workspaces without triggering tag completion (#69)
This commit is contained in:
parent
32f4b59ea1
commit
335cff15ea
@ -53,6 +53,21 @@ local function format_filepath(filename, opts)
|
|||||||
return utils.transform_path(opts, filename)
|
return utils.transform_path(opts, filename)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function fetch_lsp_workspaces(bufnr, force)
|
||||||
|
if not vim.tbl_isempty(state.lsp_workspaces) and not force then
|
||||||
|
return state.lsp_workspaces
|
||||||
|
end
|
||||||
|
|
||||||
|
local lsp_workspaces = vim.api.nvim_buf_call(bufnr, vim.lsp.buf.list_workspace_folders)
|
||||||
|
if not vim.tbl_isempty(lsp_workspaces) then
|
||||||
|
state.lsp_workspaces = lsp_workspaces
|
||||||
|
else
|
||||||
|
state.lsp_workspaces = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
return state.lsp_workspaces
|
||||||
|
end
|
||||||
|
|
||||||
local function get_workspace_tags()
|
local function get_workspace_tags()
|
||||||
-- Add user config workspaces. TODO: validate that workspaces are existing directories
|
-- Add user config workspaces. TODO: validate that workspaces are existing directories
|
||||||
local tags = {}
|
local tags = {}
|
||||||
@ -64,12 +79,8 @@ local function get_workspace_tags()
|
|||||||
table.insert(tags, "CWD")
|
table.insert(tags, "CWD")
|
||||||
|
|
||||||
-- Add LSP workpace(s)
|
-- Add LSP workpace(s)
|
||||||
local lsp_workspaces = vim.api.nvim_buf_call(state.previous_buffer, vim.lsp.buf.list_workspace_folders)
|
if not vim.tbl_isempty(fetch_lsp_workspaces(state.previous_buffer, true)) then
|
||||||
if not vim.tbl_isempty(lsp_workspaces) then
|
|
||||||
state.lsp_workspaces = lsp_workspaces
|
|
||||||
table.insert(tags, "LSP")
|
table.insert(tags, "LSP")
|
||||||
else
|
|
||||||
state.lsp_workspaces = {}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- print(vim.inspect(tags))
|
-- print(vim.inspect(tags))
|
||||||
@ -289,6 +300,15 @@ return telescope.register_extension {
|
|||||||
vim.F.if_nil(ext_config.db_safe_mode, true),
|
vim.F.if_nil(ext_config.db_safe_mode, true),
|
||||||
vim.F.if_nil(ext_config.auto_validate, true)
|
vim.F.if_nil(ext_config.auto_validate, true)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd("LspAttach", {
|
||||||
|
callback = function(args)
|
||||||
|
if not vim.tbl_isempty(fetch_lsp_workspaces(args.buf)) then
|
||||||
|
-- lsp workspaces found, remove the autocmd
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
end,
|
end,
|
||||||
exports = {
|
exports = {
|
||||||
frecency = frecency,
|
frecency = frecency,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user