-- LSP -- Global mappings. -- See `:help vim.diagnostic.*` for documentation on any of the below functions vim.keymap.set('n', 'e', vim.diagnostic.open_float) vim.keymap.set('n', '[d', vim.diagnostic.goto_prev) vim.keymap.set('n', ']d', vim.diagnostic.goto_next) vim.keymap.set('n', 'q', vim.diagnostic.setloclist) -- Use LspAttach autocommand to only map the following keys -- after the language server attaches to the current buffer vim.api.nvim_create_autocmd('LspAttach', { group = vim.api.nvim_create_augroup('UserLspConfig', {}), callback = function(ev) -- 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', 'gd', vim.lsp.buf.definition, opts) vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts) vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts) vim.keymap.set({ 'n', 'i' }, '', vim.lsp.buf.signature_help, opts) -- vim.keymap.set('n', 'wa', vim.lsp.buf.add_workleader_folder, opts) -- vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workleader_folder, opts) -- vim.keymap.set('n', 'wl', function() -- print(vim.inspect(vim.lsp.buf.list_workleader_folders())) -- end, opts) vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, opts) -- vim.keymap.set('n', 'rn', vim.lsp.buf.rename, opts) -- vim.keymap.set({ 'n', 'v' }, 'ca', vim.lsp.buf.code_action, opts) vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) vim.keymap.set('n', 'lf', function() vim.lsp.buf.format { async = true } end, opts) end, }) -- Github Copilot copilot_suggestion = require('copilot.suggestion') copilot_panel = require('copilot.panel') -- Inline suggestions vim.keymap.set('i', '', function() copilot_suggestion.accept() end) vim.keymap.set('i', '', function() copilot_suggestion.accept_word() end) -- Panel -- vim.keymap.set('n', '', function() copilot_panel.open() end) -- Telescope tabs telescope_tabs = require('telescope-tabs') vim.keymap.set('n', ',', function() telescope_tabs.list_tabs() end) vim.keymap.set('n', '`', function() telescope_tabs.go_to_previous() end) -- Hop local hop = require('hop') local directions = require('hop.hint').HintDirection vim.keymap.set('', 'f', function() hop.hint_char1({ direction = directions.AFTER_CURSOR, current_line_only = true }) end, {remap=true}) vim.keymap.set('', 'F', function() hop.hint_char1({ direction = directions.BEFORE_CURSOR, current_line_only = true }) end, {remap=true}) vim.keymap.set('', 't', function() hop.hint_char1({ direction = directions.AFTER_CURSOR, current_line_only = true, hint_offset = -1 }) end, {remap=true}) vim.keymap.set('', 'T', function() hop.hint_char1({ direction = directions.BEFORE_CURSOR, current_line_only = true, hint_offset = 1 }) end, {remap=true}) -- Lspsaga vim.keymap.set("n", "lr", ":Lspsaga rename", { noremap = true, silent = true }) -- action-preview -- This is for code actions vim.keymap.set({ "v", "n" }, "", require("actions-preview").code_actions)