diff options
author | Alex NeonXP <i@neonxp.ru> | 2024-02-18 15:18:56 +0300 |
---|---|---|
committer | Alex NeonXP <i@neonxp.ru> | 2024-02-18 15:18:56 +0300 |
commit | d3483449381b6a7ee4e62e352c699c63ddaab33a (patch) | |
tree | 6b181039580851d51629cb7e3bb139bde90e9720 /nvim/lua/keymaps.lua | |
parent | 17951e8c06f638543a19cbcaf95623ca211d6514 (diff) |
Конфиги nvim
Diffstat (limited to 'nvim/lua/keymaps.lua')
-rw-r--r-- | nvim/lua/keymaps.lua | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/nvim/lua/keymaps.lua b/nvim/lua/keymaps.lua new file mode 100644 index 0000000..8cbd8da --- /dev/null +++ b/nvim/lua/keymaps.lua @@ -0,0 +1,49 @@ +local map = vim.api.nvim_set_keymap +local opts = {noremap = true, silent = true} + +-- 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, {}) + |