From ab0d9c600b9b1777e8864bfc0b28f96073cee548 Mon Sep 17 00:00:00 2001 From: "Gustavo Silva (es00679121_prosegur)" Date: Wed, 12 Jul 2023 22:53:47 +0200 Subject: [PATCH] Add new keymaps and plugins --- init.lua | 2 +- lua/custom/configs/maps.lua | 12 +++++ lua/custom/configs/settings.lua | 6 ++- lua/custom/plugins/debug.lua | 65 ++++++++++++++------------ lua/custom/plugins/go.lua | 16 ++++++- lua/custom/plugins/goto-preview.lua | 6 +++ lua/custom/plugins/noice.lua | 16 +++++++ lua/custom/plugins/null_ls.lua | 4 +- lua/custom/plugins/rest.lua | 48 +++++++++++++++++++ lua/custom/plugins/tmux_navigator.lua | 8 ++-- lua/custom/plugins/trouble.lua | 32 +++++++++++++ spell/en.utf-8.add | 26 +++++++++++ spell/en.utf-8.add.spl | Bin 1783 -> 2226 bytes 13 files changed, 203 insertions(+), 38 deletions(-) create mode 100644 lua/custom/plugins/goto-preview.lua create mode 100644 lua/custom/plugins/noice.lua create mode 100644 lua/custom/plugins/rest.lua create mode 100644 lua/custom/plugins/trouble.lua diff --git a/init.lua b/init.lua index f9b5b3c5..a6ef5176 100644 --- a/init.lua +++ b/init.lua @@ -439,7 +439,7 @@ vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = vim.defer_fn(function() require('nvim-treesitter.configs').setup { -- Add languages to be installed here that you want installed for treesitter - ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim', 'bash' }, + ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim', 'bash', 'http', 'json' }, -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) auto_install = false, diff --git a/lua/custom/configs/maps.lua b/lua/custom/configs/maps.lua index 20f02747..c44ddca1 100644 --- a/lua/custom/configs/maps.lua +++ b/lua/custom/configs/maps.lua @@ -50,3 +50,15 @@ map("n", "s", [[:%s/\<\>//gI]]) -- Reset highlight map("n", "", "noh") +-- Hover documentation +map("n", "K", "lua vim.lsp.buf.hover()") +vim.keymap.set("n", '', vim.lsp.buf.signature_help, { desc = '[S]ignature [D]ocumentation' }) + +-- Go to referenece +vim.keymap.set("n", "gr", require('telescope.builtin').lsp_references, { desc = '[G]oto [R]reference' }) + +vim.keymap.set("n", "gpd", "lua require('goto-preview').goto_preview_definition()", { noremap = true }) +vim.keymap.set("n", "gpt", "lua require('goto-preview').goto_preview_type_definition()", { noremap = true }) +vim.keymap.set("n", "gpi", "lua require('goto-preview').goto_preview_implementation()", { noremap = true }) +vim.keymap.set("n", "gP", "lua require('goto-preview').close_all_win()", { noremap = true }) +vim.keymap.set("n", "gpr", "lua require('goto-preview').goto_preview_references()", { noremap = true }) diff --git a/lua/custom/configs/settings.lua b/lua/custom/configs/settings.lua index f9ff7f34..c7393d9a 100644 --- a/lua/custom/configs/settings.lua +++ b/lua/custom/configs/settings.lua @@ -42,8 +42,12 @@ o.timeoutlen = 500 -- Spell check opt.spelllang = 'en_us' -opt.spell = true +-- opt.spell = true -- Markdown global.mkdp_browser = '/usr/bin/firefox' +-- Fold +--o.foldmethod = 'syntax' +o.foldmethod = 'expr' +o.foldexpr = 'nvim_treesitter#foldexpr()' diff --git a/lua/custom/plugins/debug.lua b/lua/custom/plugins/debug.lua index c6c6ec18..6cdbdecd 100644 --- a/lua/custom/plugins/debug.lua +++ b/lua/custom/plugins/debug.lua @@ -30,33 +30,10 @@ return { config = function() local dap = require 'dap' local dapui = require 'dapui' + local dap_go = require 'dap-go' - require('mason-nvim-dap').setup { - -- Makes a best effort to setup the various debuggers with - -- reasonable debug configurations - automatic_setup = true, - - -- You can provide additional configuration to the handlers, - -- see mason-nvim-dap README for more information - handlers = {}, - - -- You'll need to check that you have the required things installed - -- online, please don't ask me how to install them :) - ensure_installed = { - -- Update this to ensure that you have the debuggers for the langs you want - 'delve', - }, - } - - -- Basic debugging keymaps, feel free to change to your liking! - vim.keymap.set('n', '', dap.continue, { desc = 'dap run/continue debug' }) - vim.keymap.set('n', '', dap.step_into, { desc = 'dap step into' }) - vim.keymap.set('n', '', dap.step_over, { desc = 'dap step over' }) - vim.keymap.set('n', '', dap.step_out, { desc = 'dap step out' }) - vim.keymap.set('n', 'b', dap.toggle_breakpoint, { desc = 'dap toggle breakpoint' }) - vim.keymap.set('n', 'B', function() - dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ') - end, { desc = 'dap breakpoint condition' }) + -- Install golang specific config + dap_go.setup() -- Dap UI setup -- For more information, see |:help nvim-dap-ui| @@ -79,14 +56,44 @@ return { }, }, } + + require('nvim-dap-virtual-text').setup() + require('mason-nvim-dap').setup { + -- Makes a best effort to setup the various debuggers with + -- reasonable debug configurations + automatic_setup = true, + + -- You can provide additional configuration to the handlers, + -- see mason-nvim-dap README for more information + handlers = {}, + + -- You'll need to check that you have the required things installed + -- online, please don't ask me how to install them :) + ensure_installed = { + -- Update this to ensure that you have the debuggers for the langs you want + 'delve', + }, + } + + -- Basic debugging keymaps, feel free to change to your liking! + vim.keymap.set('n', '', dap.continue, { desc = 'dap run/continue debug' }) + vim.keymap.set('n', '', dap.terminate, { desc = 'dap stop debug' }) + vim.keymap.set('n', '', dap.step_into, { desc = 'dap step into' }) + vim.keymap.set('n', '', dap.step_over, { desc = 'dap step over' }) + vim.keymap.set('n', '', dap.step_out, { desc = 'dap step out' }) + -- vim.keymap.set('n', 'dr', dap.repl.open, { desc = 'dap open repl' }) + vim.keymap.set('n', 'td', dap_go.debug_test, { desc = 'dap debug test' }) + vim.keymap.set('n', 'tl', dap_go.debug_last_test, { desc = 'dap debug last test' }) + vim.keymap.set('n', 'b', dap.toggle_breakpoint, { desc = 'dap toggle breakpoint' }) + vim.keymap.set('n', 'B', function() + dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ') + end, { desc = 'dap breakpoint condition' }) + -- toggle to see last session result. Without this ,you can't see session output in case of unhandled exception. vim.keymap.set("n", "", dapui.toggle) dap.listeners.after.event_initialized['dapui_config'] = dapui.open dap.listeners.before.event_terminated['dapui_config'] = dapui.close dap.listeners.before.event_exited['dapui_config'] = dapui.close - -- Install golang specific config - require('dap-go').setup() - require('nvim-dap-virtual-text').setup() end, } diff --git a/lua/custom/plugins/go.lua b/lua/custom/plugins/go.lua index 1cf879a2..fc75c8dd 100644 --- a/lua/custom/plugins/go.lua +++ b/lua/custom/plugins/go.lua @@ -1,3 +1,17 @@ +-- return { +-- 'fatih/vim-go', +-- } return { - 'fatih/vim-go', + "ray-x/go.nvim", + dependencies = { -- optional packages + "ray-x/guihua.lua", + "neovim/nvim-lspconfig", + "nvim-treesitter/nvim-treesitter", + }, + config = function() + require("go").setup() + end, + event = { "CmdlineEnter" }, + ft = { "go", 'gomod' }, + build = ':lua require("go.install").update_all_sync()' -- if you need to install/update all binaries } diff --git a/lua/custom/plugins/goto-preview.lua b/lua/custom/plugins/goto-preview.lua new file mode 100644 index 00000000..bbe1750f --- /dev/null +++ b/lua/custom/plugins/goto-preview.lua @@ -0,0 +1,6 @@ +return { + 'rmagatti/goto-preview', + config = function() + require('goto-preview').setup {} + end +} diff --git a/lua/custom/plugins/noice.lua b/lua/custom/plugins/noice.lua new file mode 100644 index 00000000..e2f43ae5 --- /dev/null +++ b/lua/custom/plugins/noice.lua @@ -0,0 +1,16 @@ +-- lazy.nvim +return { + "folke/noice.nvim", + event = "VeryLazy", + opts = { + -- add any options here + }, + dependencies = { + -- if you lazy-load any plugin below, make sure to add proper `module="..."` entries + "MunifTanjim/nui.nvim", + -- OPTIONAL: + -- `nvim-notify` is only needed, if you want to use the notification view. + -- If not available, we use `mini` as the fallback + -- "rcarriga/nvim-notify", + } +} diff --git a/lua/custom/plugins/null_ls.lua b/lua/custom/plugins/null_ls.lua index bb2bdad8..356bd399 100644 --- a/lua/custom/plugins/null_ls.lua +++ b/lua/custom/plugins/null_ls.lua @@ -8,8 +8,8 @@ return { null_ls.setup { sources = { null_ls.builtins.formatting.goimports_reviser, - null_ls.builtins.formatting.gofumpt, - null_ls.builtins.formatting.golines, + -- null_ls.builtins.formatting.gofumpt, + -- null_ls.builtins.formatting.golines, }, on_attach = function(client, bufnr) if client.supports_method('textDocument/formatting') then diff --git a/lua/custom/plugins/rest.lua b/lua/custom/plugins/rest.lua new file mode 100644 index 00000000..75e1e253 --- /dev/null +++ b/lua/custom/plugins/rest.lua @@ -0,0 +1,48 @@ +return { + "rest-nvim/rest.nvim", + dependencies = { "nvim-lua/plenary.nvim" }, + config = function() + local rest_client = require("rest-nvim") + + rest_client.setup { + -- Open request results in a horizontal split + result_split_horizontal = false, + -- Keep the http file buffer above|left when split horizontal|vertical + result_split_in_place = false, + -- Skip SSL verification, useful for unknown certificates + skip_ssl_verification = false, + -- Encode URL before making request + encode_url = true, + -- Highlight request on run + highlight = { + enabled = true, + timeout = 150, + }, + result = { + -- toggle showing URL, HTTP info, headers at top the of result window + show_url = true, + -- show the generated curl command in case you want to launch + -- the same request via the terminal (can be verbose) + show_curl_command = false, + show_http_info = true, + show_headers = true, + -- executables or functions for formatting response body [optional] + -- set them to false if you want to disable them + formatters = { + json = "jq", + html = function(body) + return vim.fn.system({ "tidy", "-i", "-q", "-" }, body) + end + }, + }, + -- Jump to request line on run + jump_to_request = false, + env_file = '.env', + custom_dynamic_variables = {}, + yank_dry_run = true, + } + + vim.keymap.set('n', 'rc', rest_client.run, { desc = '[R]un rest [Client]' }) + vim.keymap.set('n', 'rl', rest_client.last, { desc = '[R]un rest [Last] request' }) + end +} diff --git a/lua/custom/plugins/tmux_navigator.lua b/lua/custom/plugins/tmux_navigator.lua index 1c30d3d0..f0dde84c 100644 --- a/lua/custom/plugins/tmux_navigator.lua +++ b/lua/custom/plugins/tmux_navigator.lua @@ -2,9 +2,9 @@ return { 'christoomey/vim-tmux-navigator', lazy = false, config = function() - vim.keymap.set("n", "", "TmuxNavigateLeft", { desc = "tmux window left"}) - vim.keymap.set("n", "", "TmuxNavigateRight", { desc = "tmux window right"}) - vim.keymap.set("n", "", "TmuxNavigateDown", { desc = "tmux window down"}) - vim.keymap.set("n", "", "TmuxNavigateUp", { desc = "tmux window up"}) + vim.keymap.set("n", "", "TmuxNavigateLeft", { desc = "tmux window left"}) + vim.keymap.set("n", "", "TmuxNavigateRight", { desc = "tmux window right"}) + vim.keymap.set("n", "", "TmuxNavigateDown", { desc = "tmux window down"}) + vim.keymap.set("n", "", "TmuxNavigateUp", { desc = "tmux window up"}) end, } diff --git a/lua/custom/plugins/trouble.lua b/lua/custom/plugins/trouble.lua new file mode 100644 index 00000000..760b3fb6 --- /dev/null +++ b/lua/custom/plugins/trouble.lua @@ -0,0 +1,32 @@ +return { + "folke/trouble.nvim", + config = function(_, opts) + require('trouble').setup(opts) + + vim.keymap.set("n", "xx", "TroubleToggle", + { silent = true, noremap = true } + ) + vim.keymap.set("n", "xw", "TroubleToggle workspace_diagnostics", + { silent = true, noremap = true } + ) + vim.keymap.set("n", "xd", "TroubleToggle document_diagnostics", + { silent = true, noremap = true } + ) + vim.keymap.set("n", "xl", "TroubleToggle loclist", + { silent = true, noremap = true } + ) + vim.keymap.set("n", "xq", "TroubleToggle quickfix", + { silent = true, noremap = true } + ) + vim.keymap.set("n", "gR", "TroubleToggle lsp_references", + { silent = true, noremap = true } + ) + + end, + dependencies = { "nvim-tree/nvim-web-devicons" }, + opts = { + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + }, +} diff --git a/spell/en.utf-8.add b/spell/en.utf-8.add index 35a99995..38f500c8 100644 --- a/spell/en.utf-8.add +++ b/spell/en.utf-8.add @@ -124,3 +124,29 @@ AccountNumber UCode ParentUUID ContentData +api +v2 +serviceOrders +CRM +PT2300000321 +ucode +ucodes +uCode +systemCode +apiVersion +serviceOrder +serviceOrderData +ServiceOrder +UUID +PT0200008165 +f2d7bf7 +b191 +a2a +a05f +de09d4ea0e +ca5ded76a9d +d34 +a893 +b1177a +dataItem +CountryCode diff --git a/spell/en.utf-8.add.spl b/spell/en.utf-8.add.spl index 41f733138436289302484bf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