Move telescope reference picker to lsp attach handler

This commit is contained in:
Talia 2023-10-25 14:52:37 +02:00
parent d9be01655a
commit 8ee15aeb6c
2 changed files with 6 additions and 6 deletions

View file

@ -1,5 +1,3 @@
local opts = { noremap=true, silent=true }
return function(_, bufnr) return function(_, bufnr)
-- Enable completion triggered by <c-x><c-o> -- Enable completion triggered by <c-x><c-o>
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
@ -20,7 +18,7 @@ return function(_, bufnr)
end, bufopts) end, bufopts)
vim.api.nvim_buf_create_user_command(bufnr, "LspSetWorkspace", function() vim.api.nvim_buf_create_user_command(bufnr, "LspSetWorkspace", function()
for i, workspace in ipairs(vim.lsp.buf.list_workspace_folders()) do for _, workspace in ipairs(vim.lsp.buf.list_workspace_folders()) do
vim.lsp.buf.remove_workspace_folder(workspace) vim.lsp.buf.remove_workspace_folder(workspace)
end end
vim.lsp.buf.add_workspace_folder(vim.cmd("pwd")) vim.lsp.buf.add_workspace_folder(vim.cmd("pwd"))
@ -29,7 +27,11 @@ return function(_, bufnr)
vim.keymap.set('n', '<leader>D', vim.lsp.buf.type_definition, bufopts) vim.keymap.set('n', '<leader>D', vim.lsp.buf.type_definition, bufopts)
vim.keymap.set('n', '<leader>r', vim.lsp.buf.rename, bufopts) vim.keymap.set('n', '<leader>r', vim.lsp.buf.rename, bufopts)
vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, bufopts) vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, bufopts)
if require("telescope") then
vim.keymap.set('n', 'gr', function() vim.cmd("Telescope lsp_references") end, bufopts)
else
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
end
--vim.keymap.set('n', '<leader>f', vim.lsp.buf.formatting, bufopts) --vim.keymap.set('n', '<leader>f', vim.lsp.buf.formatting, bufopts)
vim.api.nvim_buf_create_user_command(bufnr, "Format", vim.lsp.buf.format, {}) vim.api.nvim_buf_create_user_command(bufnr, "Format", vim.lsp.buf.format, {})

View file

@ -506,8 +506,6 @@ nnoremap <leader>! :Telescope diagnostics<CR>
nnoremap <leader>? :Telescope keymaps<CR> nnoremap <leader>? :Telescope keymaps<CR>
nnoremap <leader>f :Telescope find_files<CR> nnoremap <leader>f :Telescope find_files<CR>
nnoremap <leader>b :Telescope buffers<CR> nnoremap <leader>b :Telescope buffers<CR>
nnoremap <leader>ld :Telescope lsp_definitions<CR>
nnoremap <leader>lr :Telescope lsp_references<CR>
nnoremap <leader>ls :Telescope lsp_document_symbols<CR> nnoremap <leader>ls :Telescope lsp_document_symbols<CR>
nnoremap <leader>lS :Telescope lsp_workspace_symbols<CR> nnoremap <leader>lS :Telescope lsp_workspace_symbols<CR>
nnoremap <leader>ll :Telescope lsp_ nnoremap <leader>ll :Telescope lsp_