feat(lsp): updated lsp mappings to utilize telescope, update telescope settings
This commit is contained in:
parent
6dc398b060
commit
c61dc5acf6
3 changed files with 49 additions and 64 deletions
|
@ -2,6 +2,32 @@ local actions = require('telescope.actions')
|
|||
local mappings = require('cosmic.core.file-navigation.mappings').mappings()
|
||||
local icons = require('cosmic.core.theme.icons')
|
||||
|
||||
local opts_cursor = {
|
||||
initial_mode = 'normal',
|
||||
sorting_strategy = 'ascending',
|
||||
layout_strategy = 'cursor',
|
||||
preview_title = false,
|
||||
results_title = false,
|
||||
layout_config = {
|
||||
width = 0.3,
|
||||
height = 0.3,
|
||||
},
|
||||
mappings = mappings,
|
||||
}
|
||||
|
||||
local opts_vertical = {
|
||||
initial_mode = 'normal',
|
||||
sorting_strategy = 'ascending',
|
||||
layout_strategy = 'vertical',
|
||||
results_title = false,
|
||||
layout_config = {
|
||||
width = 0.3,
|
||||
height = 0.5,
|
||||
prompt_position = 'top',
|
||||
mirror = true,
|
||||
},
|
||||
}
|
||||
|
||||
require('telescope').setup({
|
||||
defaults = {
|
||||
prompt_prefix = '🔍 ',
|
||||
|
@ -41,66 +67,25 @@ require('telescope').setup({
|
|||
sort_mru = true,
|
||||
preview_title = false,
|
||||
},
|
||||
lsp_references = {
|
||||
initial_mode = 'normal',
|
||||
sorting_strategy = 'ascending',
|
||||
layout_strategy = 'cursor',
|
||||
preview_title = false,
|
||||
results_title = false,
|
||||
prompt_title = 'References',
|
||||
layout_config = {
|
||||
width = 0.4,
|
||||
height = 0.4,
|
||||
},
|
||||
},
|
||||
lsp_code_actions = {
|
||||
initial_mode = 'normal',
|
||||
sorting_strategy = 'ascending',
|
||||
layout_strategy = 'cursor',
|
||||
preview = false,
|
||||
lsp_code_actions = vim.tbl_deep_extend('force', opts_cursor, {
|
||||
prompt_title = 'Code Actions',
|
||||
results_title = '',
|
||||
layout_config = {
|
||||
width = 0.2,
|
||||
height = 0.3,
|
||||
},
|
||||
},
|
||||
lsp_range_code_actions = {
|
||||
initial_mode = 'normal',
|
||||
sorting_strategy = 'ascending',
|
||||
layout_strategy = 'cursor',
|
||||
preview = false,
|
||||
}),
|
||||
lsp_range_code_actions = vim.tbl_deep_extend('force', opts_vertical, {
|
||||
prompt_title = 'Code Actions',
|
||||
results_title = '',
|
||||
layout_config = {
|
||||
width = 0.3,
|
||||
height = 0.3,
|
||||
},
|
||||
},
|
||||
lsp_document_diagnostics = {
|
||||
initial_mode = 'normal',
|
||||
sorting_strategy = 'ascending',
|
||||
layout_strategy = 'vertical',
|
||||
prompt_title = 'Diagnostics',
|
||||
results_title = '',
|
||||
layout_config = {
|
||||
width = 0.5,
|
||||
height = 0.5,
|
||||
prompt_position = 'top'
|
||||
},
|
||||
}),
|
||||
lsp_document_diagnostics = vim.tbl_deep_extend('force', opts_vertical, {
|
||||
prompt_title = 'Document Diagnostics',
|
||||
mappings = mappings,
|
||||
},
|
||||
lsp_definitions = {
|
||||
layout_strategy = 'cursor',
|
||||
}),
|
||||
lsp_implementations = vim.tbl_deep_extend('force', opts_cursor, {
|
||||
prompt_title = 'Implementations',
|
||||
}),
|
||||
lsp_definitions = vim.tbl_deep_extend('force', opts_cursor, {
|
||||
prompt_title = 'Definitions',
|
||||
preview_title = false,
|
||||
results_title = false,
|
||||
layout_config = {
|
||||
width = 0.5,
|
||||
height = 0.5,
|
||||
},
|
||||
mappings = mappings,
|
||||
},
|
||||
}),
|
||||
lsp_references = vim.tbl_deep_extend('force', opts_cursor, {
|
||||
prompt_title = 'References',
|
||||
}),
|
||||
find_files = {
|
||||
prompt_title = '✨ Search Project ✨',
|
||||
mappings = mappings,
|
||||
|
|
|
@ -22,7 +22,7 @@ function M.init()
|
|||
signs = true,
|
||||
severity_sort = true,
|
||||
float = {
|
||||
show_header = true,
|
||||
show_header = false,
|
||||
source = 'always',
|
||||
border = 'single',
|
||||
},
|
||||
|
|
|
@ -4,18 +4,18 @@ local map = require('cosmic.utils').map
|
|||
local opts = { noremap = true, silent = true }
|
||||
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
map('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>', opts)
|
||||
map('n', 'gd', '<cmd>lua vim.lsp.buf.declaration()<cr>', opts)
|
||||
map('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>', opts)
|
||||
map('n', 'gt', '<cmd>lua vim.lsp.buf.type_definition()<cr>', opts)
|
||||
map('n', 'gd', '<cmd>lua require("telescope.builtin").lsp_definitions()<cr>', opts)
|
||||
map('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>', opts)
|
||||
map('n', 'gi', '<cmd>lua require("telescope.builtin").lsp_implementations()<cr>', opts)
|
||||
map('n', 'gt', '<cmd>lua require("telescope.builtin").lsp_type_definitions()<cr>', opts)
|
||||
map('n', 'gr', '<cmd>lua require("telescope.builtin").lsp_references()<cr>', opts)
|
||||
map('n', 'gn', '<cmd>lua require("cosmic.core.theme.ui").rename()<cr>', opts)
|
||||
|
||||
-- diagnostics
|
||||
map('n', '[g', '<cmd>lua vim.diagnostic.goto_prev({ float = { show_header = false }})<cr>', opts)
|
||||
map('n', ']g', '<cmd>lua vim.diagnostic.goto_next({ float = { show_header = false }})<cr>', opts)
|
||||
map('n', '[g', '<cmd>lua vim.diagnostic.goto_prev()<cr>', opts)
|
||||
map('n', ']g', '<cmd>lua vim.diagnostic.goto_next()<cr>', opts)
|
||||
map('n', 'ge', '<cmd>lua vim.diagnostic.open_float(0, { scope = "line", })<cr>', opts)
|
||||
map('n', '<space>ge', ':telescope lsp_document_diagnostics<cr>', opts)
|
||||
map('n', '<space>ge', '<cmd>lua require("telescope.builtin").lsp_document_diagnostics()<cr>', opts)
|
||||
map('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>', opts)
|
||||
map('n', '<space>ga', '<cmd>lua require("telescope.builtin").lsp_code_actions()<cr>', opts)
|
||||
map('v', '<space>ga', '<cmd>lua require("telescope.builtin").lsp_range_code_actions()<cr>', opts)
|
||||
|
|
Loading…
Add table
Reference in a new issue