From 49c69503394a55512ecbaf73612f7f5cc3a05da9 Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Wed, 6 Apr 2022 23:59:31 +0300 Subject: nvim: update nvim_lsp mappings --- .config/nvim/lua/mappings.lua | 3 --- .config/nvim/lua/plugin_settings.lua | 45 +++++++++++++++++------------------- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/.config/nvim/lua/mappings.lua b/.config/nvim/lua/mappings.lua index 1acc6a2..3a37584 100644 --- a/.config/nvim/lua/mappings.lua +++ b/.config/nvim/lua/mappings.lua @@ -15,9 +15,6 @@ end local cmd = vim.cmd local M = {} --- edit vimrc \ev -map('n', 'ev', ':tabnew:e ~/.config/nvim/init.lua') - -- brute force deasciify everything map('n', 'tc', 'TurkishDeasciifyForce()', {expr = true}) map('x', 'tc', 'TurkishDeasciifyForce()', {expr = true}) diff --git a/.config/nvim/lua/plugin_settings.lua b/.config/nvim/lua/plugin_settings.lua index 0eb0e94..cb27343 100644 --- a/.config/nvim/lua/plugin_settings.lua +++ b/.config/nvim/lua/plugin_settings.lua @@ -319,34 +319,31 @@ cmp.setup({ -- nvim-lsp {{{ -- local nvim_lsp = require('lspconfig') -local on_attach = function(client, bufnr) - local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end - local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end +-- Mappings. +local opts = { noremap=true, silent=true } +vim.api.nvim_set_keymap('n', 'e', 'lua vim.diagnostic.open_float()', opts) +vim.api.nvim_set_keymap('n', '[d', 'lua vim.diagnostic.goto_prev()', opts) +vim.api.nvim_set_keymap('n', ']d', 'lua vim.diagnostic.goto_next()', opts) +vim.api.nvim_set_keymap('n', 'q', 'lua vim.diagnostic.setloclist()', opts) +local on_attach = function(client, bufnr) -- Enable completion triggered by - buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') - - -- Mappings. - local opts = { noremap=true, silent=true } + vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') -- See `:help vim.lsp.*` for documentation on any of the below functions - buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) - buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) - buf_set_keymap('n', 'vh', 'lua vim.lsp.buf.hover()', opts) - buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) - buf_set_keymap('n', 'gh', 'lua vim.lsp.buf.signature_help()', opts) - buf_set_keymap('n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) - buf_set_keymap('n', 'wd', 'lua vim.lsp.buf.remove_workspace_folder()', opts) - buf_set_keymap('n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) - buf_set_keymap('n', 'D', 'lua vim.lsp.buf.type_definition()', opts) - buf_set_keymap('n', 'rn', 'lua vim.lsp.buf.rename()', opts) - buf_set_keymap('n', 'ca', 'lua vim.lsp.buf.code_action()', opts) - buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) - buf_set_keymap('n', 'd', 'lua vim.lsp.diagnostic.show_line_diagnostics()', opts) - buf_set_keymap('n', '[d', 'lua vim.lsp.diagnostic.goto_prev()', opts) - buf_set_keymap('n', ']d', 'lua vim.lsp.diagnostic.goto_next()', opts) - buf_set_keymap('n', 'q', 'lua vim.lsp.diagnostic.set_loclist()', opts) - buf_set_keymap('n', 'fm', 'lua vim.lsp.buf.formatting()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', 'lua vim.lsp.buf.declaration()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', 'lua vim.lsp.buf.definition()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'vh', 'lua vim.lsp.buf.hover()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gh', 'lua vim.lsp.buf.implementation()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', '', 'lua vim.lsp.buf.signature_help()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'D', 'lua vim.lsp.buf.type_definition()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'rn', 'lua vim.lsp.buf.rename()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ca', 'lua vim.lsp.buf.code_action()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', 'lua vim.lsp.buf.references()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'fm', 'lua vim.lsp.buf.formatting()', opts) end local servers = { 'rust_analyzer', 'jedi_language_server', 'texlab', 'clangd' } -- cgit v1.2.3-70-g09d2