feat(lsp): better telescope and lsp

Signed-off-by: Ryan <ryan@alien.gov>
This commit is contained in:
Ryan 2023-12-12 17:02:50 +08:00
parent 43219b32cb
commit 082705f561
No known key found for this signature in database
GPG Key ID: DB5B3AC49EEFD2A5
3 changed files with 39 additions and 21 deletions

View File

@ -33,6 +33,7 @@
"rainbow_csv.nvim": { "branch": "main", "commit": "a520dabf1c74d7d7d8341dd3f3570063ef51b3aa" },
"range-highlight.nvim": { "branch": "master", "commit": "8b5e8ccb3460b2c3675f4639b9f54e64eaab36d9" },
"symbols-outline.nvim": { "branch": "master", "commit": "512791925d57a61c545bc303356e8a8f7869763c" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" },
"telescope.nvim": { "branch": "master", "commit": "6213322ab56eb27356fdc09a5078e41e3ea7f3bc" },
"ultimate-autopair.nvim": { "branch": "v0.6", "commit": "41d8b52183df39096d5a2918467cd6266282f64b" },
"vim-matchup": { "branch": "master", "commit": "269f9bea87e20a01438085eb13df539929a12727" },

View File

@ -144,22 +144,37 @@ local plugins = {
"andymass/vim-matchup",
event = "BufEnter"
},
{
'nvim-telescope/telescope-fzf-native.nvim',
build = 'make',
lazy = true
},
{
"nvim-telescope/telescope.nvim",
dependencies = { 'nvim-lua/plenary.nvim' },
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-telescope/telescope-fzf-native.nvim'
},
event = "CmdlineEnter",
keys = {
vim.keymap.set('', '<leader>t/', ':Telescope lsp_dynamic_workspace_symbols<cr>'),
vim.keymap.set('', '<leader>tg', ':Telescope live_grep<cr>'),
vim.keymap.set('', '<leader>tb', ':Telescope buffers<cr>'),
vim.keymap.set('', '<leader>tf', ':Telescope fd<cr>'),
vim.keymap.set('n', '<leader>f/', ':Telescope lsp_dynamic_workspace_symbols<cr>'),
vim.keymap.set('n', '<leader>fg', ':Telescope live_grep<cr>'),
vim.keymap.set('n', '<leader>fb', ':Telescope buffers<cr>'),
vim.keymap.set('n', '<leader>ff', ':Telescope find_files<cr>'),
vim.keymap.set('n', '<leader>fd', ':Telescope diagnostics'),
vim.keymap.set('n', '<leader>fs', ':Telescope spell_suggest'),
},
opts = {
config = function()
require("telescope").setup {
defaults = {
layout_strategy = 'flex',
layout_config = { flex = { flip_columns = 144 } },
layout_config = {
flex = { flip_columns = 144 }
},
},
}
require('telescope').load_extension('fzf')
end
},
{
'kevinhwang91/nvim-bqf',

View File

@ -10,28 +10,30 @@ vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
callback = function(ev)
-- Enable completion triggered by <c-x><c-o>
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
-- vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
-- Buffer local mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local opts = { buffer = ev.buf }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
vim.keymap.set('n', '<leader>K', vim.lsp.buf.hover, opts)
vim.keymap.set({ 'n', 'i' }, '<C-k>', vim.lsp.buf.signature_help, opts)
vim.keymap.set('n', '<leader>wa', vim.lsp.buf.add_workspace_folder, opts)
vim.keymap.set('n', '<leader>wr', vim.lsp.buf.remove_workspace_folder, opts)
vim.keymap.set('n', '<leader>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, opts)
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
vim.keymap.set({ 'n', 'v' }, '<leader>ca', vim.lsp.buf.code_action, opts)
vim.keymap.set('n', '<leader>fm', function()
vim.lsp.buf.format { async = true }
end, opts)
vim.keymap.set("n", "<leader>gr", vim.lsp.buf.references, opts)
vim.keymap.set('n', '<leader>D', vim.lsp.buf.type_definition, opts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
vim.keymap.set('n', '<leader>K', vim.lsp.buf.hover, opts)
vim.keymap.set('n', '<leader>ci', vim.lsp.buf.incoming_calls, opts)
vim.keymap.set('n', '<leader>co', vim.lsp.buf.outgoing_calls, opts)
vim.keymap.set('n', '<leader>gi', vim.lsp.buf.implementation, opts)
vim.keymap.set('n', '<leader>gr', vim.lsp.buf.references, opts)
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
vim.keymap.set('n', '<leader>wa', vim.lsp.buf.add_workspace_folder, opts)
vim.keymap.set('n', '<leader>wr', vim.lsp.buf.remove_workspace_folder, opts)
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
vim.keymap.set({ 'n', 'i' }, '<C-k>', vim.lsp.buf.signature_help, opts)
vim.keymap.set({ 'n', 'v' }, '<leader>ca', vim.lsp.buf.code_action, opts)
end,
})