From d3483449381b6a7ee4e62e352c699c63ddaab33a Mon Sep 17 00:00:00 2001 From: Alex NeonXP Date: Sun, 18 Feb 2024 15:18:56 +0300 Subject: Конфиги nvim MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nvim/lua/keymaps.lua | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 nvim/lua/keymaps.lua (limited to 'nvim/lua/keymaps.lua') 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', '', ':NvimTreeToggle', opts) + +-- Telescope +map('n', 'ff', 'Telescope find_files', opts) +map('n', 'fg', 'Telescope live_grep', opts) +map('n', 'fb', 'Telescope buffers', opts) + +-- LSP +--map('n', 'e', vim.diagnostic.open_float, opts) +--map('n', '[d', vim.diagnostic.goto_prev, opts) +--map('n', ']d', vim.diagnostic.goto_next, opts) +--map('n', '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', '', vim.lsp.buf.signature_help, bufopts) + map('n', 'wa', vim.lsp.buf.add_workspace_folder, bufopts) + map('n', 'wr', vim.lsp.buf.remove_workspace_folder, bufopts) + map('n', 'wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, bufopts) + map('n', 'D', vim.lsp.buf.type_definition, bufopts) + map('n', 'rn', vim.lsp.buf.rename, bufopts) + map('n', 'ca', vim.lsp.buf.code_action, bufopts) + map('n', 'gr', vim.lsp.buf.references, bufopts) + map('n', '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', '', change_root_to_global_cwd, {}) + -- cgit v1.2.3