75 lines
3.1 KiB
Lua
75 lines
3.1 KiB
Lua
-- LSP
|
|
-- Global mappings.
|
|
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
|
vim.keymap.set('n', '<leader>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', '<leader>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' }, '<C-k>', vim.lsp.buf.signature_help, opts)
|
|
-- vim.keymap.set('n', '<leader>wa', vim.lsp.buf.add_workleader_folder, opts)
|
|
-- vim.keymap.set('n', '<leader>wr', vim.lsp.buf.remove_workleader_folder, opts)
|
|
-- vim.keymap.set('n', '<leader>wl', function()
|
|
-- print(vim.inspect(vim.lsp.buf.list_workleader_folders()))
|
|
-- end, opts)
|
|
vim.keymap.set('n', '<leader>D', vim.lsp.buf.type_definition, 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', 'gr', vim.lsp.buf.references, opts)
|
|
vim.keymap.set('n', '<leader>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', '<C-J>', function() copilot_suggestion.accept() end)
|
|
vim.keymap.set('i', '<C-L>', function() copilot_suggestion.accept_word() end)
|
|
|
|
-- Panel
|
|
-- vim.keymap.set('n', '<C-;>', function() copilot_panel.open() end)
|
|
|
|
-- Telescope tabs
|
|
telescope_tabs = require('telescope-tabs')
|
|
vim.keymap.set('n', '<leader><TAB>,', function() telescope_tabs.list_tabs() end)
|
|
vim.keymap.set('n', '<leader><TAB>`', 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})
|
|
|
|
-- Inc Rename
|
|
vim.keymap.set("n", "<leader>lr", ":IncRename ")
|
|
|
|
-- action-preview
|
|
-- This is for code actions
|
|
vim.keymap.set({ "v", "n" }, "<C-.>", require("actions-preview").code_actions)
|