Consistent filepath display and code cleanup. (#839)

BREAKING CHANGE: see :help telescope.changelog-839 for more information

Co-authored-by: Simon Hauser <Simon-Hauser@outlook.de>
This commit is contained in:
caojoshua
2021-07-08 01:30:44 -07:00
committed by GitHub
parent 38907ce7d7
commit d5a8e48aa6
11 changed files with 165 additions and 137 deletions

View File

@@ -492,7 +492,7 @@ files.current_buffer_tags = function(opts)
return files.tags(vim.tbl_extend("force", {
prompt_title = 'Current Buffer Tags',
only_current_file = true,
hide_filename = true,
path_display = 'hidden',
}, opts))
end

View File

@@ -118,8 +118,6 @@ builtin.current_buffer_fuzzy_find = require('telescope.builtin.files').current_b
---@param opts table: options to pass to the picker
---@field ctags_file string: specify a particular ctags file to use
---@field show_line boolean: if true, shows the content of the line the tag is found on in the picker (default is true)
---@field shorten_path boolean: if true, makes file paths shown in picker use one letter for folders (default is true)
---@field hide_filename boolean: if true, hides the name of the file in the current picker (default is false)
builtin.tags = require('telescope.builtin.files').tags
--- Lists all of the tags for the currently open buffer, with a preview
@@ -289,8 +287,6 @@ builtin.spell_suggest = require('telescope.builtin.internal').spell_suggest
--- Lists the tag stack for the current window, jumps to tag on `<cr>`
---@param opts table: options to pass to the picker
---@field shorten_path boolean: if true, makes file paths shown in picker use one letter for folders (default is true)
---@field hide_filename boolean: if true, hides the name of the file in the current picker (default is true)
builtin.tagstack = require('telescope.builtin.internal').tagstack
--- Lists items from Vim's jumplist, jumps to location on `<cr>`
@@ -305,7 +301,6 @@ builtin.jumplist = require('telescope.builtin.internal').jumplist
--- Lists LSP references for word under the cursor, jumps to reference on `<cr>`
---@param opts table: options to pass to the picker
---@field shorten_path boolean: if true, makes file paths shown in picker use one letter for folders (default is false)
builtin.lsp_references = require('telescope.builtin.lsp').references
--- Goto the definition of the word under the cursor, if there's only one, otherwise show all options in Telescope
@@ -336,9 +331,7 @@ builtin.lsp_document_symbols = require('telescope.builtin.lsp').document_symbols
--- - Default keymaps:
--- - `<C-l>`: show autocompletion menu to prefilter your query by type of symbol you want to see (i.e. `:variable:`)
---@param opts table: options to pass to the picker
---@field shorten_path boolean: if true, makes file paths shown in picker use one letter for folders (default is false)
---@field ignore_filename string: file(s) to ignore
---@field hide_filename boolean: if true, hides the name of the file in the current picker (default is false)
---@field symbols string|table: filter results by symbol kind(s)
builtin.lsp_workspace_symbols = require('telescope.builtin.lsp').workspace_symbols
@@ -346,7 +339,6 @@ builtin.lsp_workspace_symbols = require('telescope.builtin.lsp').workspace_symbo
--- - Default keymaps:
--- - `<C-l>`: show autocompletion menu to prefilter your query by type of symbol you want to see (i.e. `:variable:`)
---@param opts table: options to pass to the picker
---@field hide_filename boolean: if true, hides the name of the file in the current picker (default is false)
builtin.lsp_dynamic_workspace_symbols = require('telescope.builtin.lsp').dynamic_workspace_symbols
--- Lists LSP diagnostics for the current buffer
@@ -355,7 +347,6 @@ builtin.lsp_dynamic_workspace_symbols = require('telescope.builtin.lsp').dynamic
--- - Default keymaps:
--- - `<C-l>`: show autocompletion menu to prefilter your query with the diagnostic you want to see (i.e. `:warning:`)
---@param opts table: options to pass to the picker
---@field hide_filename boolean: if true, hides the name of the file in the current picker (default is false)
---@field severity string|number: filter diagnostics by severity name (string) or id (number)
---@field severity_limit string|number: keep diagnostics equal or more severe wrt severity name (string) or id (number)
---@field severity_bound string|number: keep diagnostics equal or less severe wrt severity name (string) or id (number)
@@ -369,7 +360,6 @@ builtin.lsp_document_diagnostics = require('telescope.builtin.lsp').diagnostics
--- - Default keymaps:
--- - `<C-l>`: show autocompletion menu to prefilter your query with the diagnostic you want to see (i.e. `:warning:`)
---@param opts table: options to pass to the picker
---@field hide_filename boolean: if true, hides the name of the file in the current picker (default is false)
---@field severity string|number: filter diagnostics by severity name (string) or id (number)
---@field severity_limit string|number: keep diagnostics equal or more severe wrt severity name (string) or id (number)
---@field severity_bound string|number: keep diagnostics equal or less severe wrt severity name (string) or id (number)

View File

@@ -19,7 +19,7 @@ local internal = {}
-- vim.fn.setreg("+", "nnoremap $TODO :lua require('telescope.builtin').<whatever>()<CR>")
-- TODO: Can we just do the names instead?
internal.builtin = function(opts)
opts.hide_filename = utils.get_default(opts.hide_filename, true)
opts.path_display = utils.get_default(opts.path_display, "hidden")
opts.ignore_filename = utils.get_default(opts.ignore_filename, true)
opts.include_extensions = utils.get_default(opts.include_extensions, false)

View File

@@ -15,8 +15,6 @@ local conf = require('telescope.config').values
local lsp = {}
lsp.references = function(opts)
opts.shorten_path = utils.get_default(opts.shorten_path, true)
local params = vim.lsp.util.make_position_params()
params.context = { includeDeclaration = true }
@@ -250,8 +248,6 @@ lsp.range_code_actions = function(opts)
end
lsp.workspace_symbols = function(opts)
opts.shorten_path = utils.get_default(opts.shorten_path, true)
local params = {query = opts.query or ''}
local results_lsp, err = vim.lsp.buf_request_sync(0, "workspace/symbol", params, opts.timeout or 10000)
if err then
@@ -283,7 +279,6 @@ lsp.workspace_symbols = function(opts)
end
opts.ignore_filename = utils.get_default(opts.ignore_filename, false)
opts.hide_filename = utils.get_default(opts.hide_filename, false)
pickers.new(opts, {
prompt_title = 'LSP Workspace Symbols',
@@ -337,7 +332,7 @@ lsp.diagnostics = function(opts)
return
end
opts.hide_filename = utils.get_default(opts.hide_filename, true)
opts.path_display = utils.get_default(opts.path_display, 'hidden')
pickers.new(opts, {
prompt_title = 'LSP Document Diagnostics',
finder = finders.new_table {
@@ -354,7 +349,7 @@ end
lsp.workspace_diagnostics = function(opts)
opts = utils.get_default(opts, {})
opts.hide_filename = utils.get_default(opts.hide_filename, false)
opts.path_display = utils.get_default(opts.path_display, {})
opts.prompt_title = 'LSP Workspace Diagnostics'
opts.get_all = true
lsp.diagnostics(opts)