51 lines
1.9 KiB
Lua
51 lines
1.9 KiB
Lua
local map = vim.api.nvim_set_keymap
|
|
local opts = {noremap = true, silent = true}
|
|
|
|
vim.g.mapleader = " "
|
|
|
|
-- Tree
|
|
map('n', '<C-h>', ':NvimTreeToggle<CR>', opts)
|
|
|
|
-- Telescope
|
|
map('n', '<leader>ff', '<cmd>Telescope find_files<CR>', opts)
|
|
map('n', '<leader>fg', '<cmd>Telescope live_grep<CR>', opts)
|
|
map('n', '<leader>fb', '<cmd>Telescope buffers<CR>', opts)
|
|
|
|
-- LSP
|
|
-- map('n', '<leader>e', vim.diagnostic.open_float, opts)
|
|
-- map('n', '[d', vim.diagnostic.goto_prev, opts)
|
|
-- map('n', ']d', vim.diagnostic.goto_next, opts)
|
|
-- map('n', '<leader>q', vim.diagnostic.setloclist, opts)
|
|
|
|
local on_attach = function(client, bufnr)
|
|
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
|
|
|
local bufopts = { noremap=true, silent=true, buffer=bufnr }
|
|
|
|
-- стандартные горячие клавиши для LSP, больше в документации
|
|
-- https://github.com/neovim/nvim-lspconfig
|
|
map('n', 'gD', vim.lsp.buf.declaration, bufopts)
|
|
map('n', 'gd', vim.lsp.buf.definition, bufopts)
|
|
map('n', 'K', vim.lsp.buf.hover, bufopts)
|
|
map('n', 'gi', vim.lsp.buf.implementation, bufopts)
|
|
map('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
|
|
map('n', '<leader>wa', vim.lsp.buf.add_workspace_folder, bufopts)
|
|
map('n', '<leader>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
|
|
map('n', '<leader>wl', function()
|
|
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
|
end, bufopts)
|
|
map('n', '<leader>D', vim.lsp.buf.type_definition, bufopts)
|
|
map('n', '<leader>rn', vim.lsp.buf.rename, bufopts)
|
|
map('n', '<leader>ca', vim.lsp.buf.code_action, bufopts)
|
|
map('n', 'gr', vim.lsp.buf.references, bufopts)
|
|
map('n', '<leader>f', vim.lsp.buf.formatting, bufopts)
|
|
end
|
|
|
|
local function change_root_to_global_cwd()
|
|
local api = require("nvim-tree.api")
|
|
local global_cwd = vim.fn.getcwd(-1, -1)
|
|
api.tree.change_root(global_cwd)
|
|
end
|
|
|
|
vim.keymap.set('n', '<C-c>', change_root_to_global_cwd, {})
|
|
|