From d20aea7ca4294b963b8edfc1032270bfe3d4e8d5 Mon Sep 17 00:00:00 2001 From: PeteChu Date: Sat, 1 Apr 2023 14:03:26 +0700 Subject: [PATCH] * chore(defaults.lua): add new options for vim * feat(keymaps.lua): add new keymaps for various actions * feat(treesitter.lua): add treesitter configuration for terraform language * chore(init.lua): comment out unused keymap for signature help * feat(plugins): add undotree plugin * feat(plugins): add lsp_signature plugin and setup configuration --- after/plugin/defaults.lua | 8 ++++++- after/plugin/keymaps.lua | 36 +++++++++++++++++++++++++++- after/plugin/treesitter.lua | 5 ++++ init.lua | 2 +- lua/custom/plugins/init.lua | 1 + lua/custom/plugins/lsp_signature.lua | 6 +++++ 6 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 after/plugin/treesitter.lua create mode 100644 lua/custom/plugins/lsp_signature.lua diff --git a/after/plugin/defaults.lua b/after/plugin/defaults.lua index 77baf46f..36bec0f2 100644 --- a/after/plugin/defaults.lua +++ b/after/plugin/defaults.lua @@ -1,4 +1,10 @@ vim.opt.relativenumber = true vim.opt.expandtab = true -vim.opt.smarttab = true \ No newline at end of file +vim.opt.smarttab = true + +vim.opt.incsearch = true + +vim.opt.scrolloff = 8 + +vim.opt.colorcolumn = "80" \ No newline at end of file diff --git a/after/plugin/keymaps.lua b/after/plugin/keymaps.lua index 54731f87..55d258c3 100644 --- a/after/plugin/keymaps.lua +++ b/after/plugin/keymaps.lua @@ -22,4 +22,38 @@ keymap("n", "", "k", opts) keymap("n", "", "l", opts) -- Nvimtree -keymap('n', 'n', ":NvimTreeToggle", {silent = true, noremap = true}) \ No newline at end of file +keymap('n', 'n', ":NvimTreeToggle", {silent = true, noremap = true, desc = "Toggle [N]vimtree"}) + +-- UndoTree +keymap('n', 'u', ":UndotreeToggle", { desc = "Toggle [U]ndo tree" }) + +-- Move line +keymap('v', 'J', ":m '>+1gv=gv", {noremap = true}) +keymap('v', 'K', ":m '<-2gv=gv", {noremap = true}) + +-- Search cursor in the middle +keymap('n', 'n', "nzzzv") +keymap('n', 'N', "Nzzzv") + +-- replace without copy current selected +keymap('x', 'p', "\"_dp") + +-- yank to system clipboard +keymap('n', 'y', "\"+y", { desc = "[Y]ank to clipboard" }) +keymap('v', 'y', "\"+y", { desc = "[Y]ank to clipboard" }) +keymap('n', 'Y', "\"+Y", { desc = "[Y]ank to clipboard" }) + +-- Quickfix +keymap('n', "", "cnextzz") +keymap('n', "", "cprevzz") +keymap('n', "k", "lnextzz") +keymap('n', "j", "lprevzz") + +-- replace selected word in the file +keymap("n", "R", [[:%s/\<\>//gI]], { desc = "[R]eplace words in the file" }) + +-- Make file executable +keymap("n", "x", "!chmod +x %", { silent = true, desc = "Make [X]ecutable file" }) + +-- Do nothing +keymap("n", "Q", "") \ No newline at end of file diff --git a/after/plugin/treesitter.lua b/after/plugin/treesitter.lua new file mode 100644 index 00000000..e98b3416 --- /dev/null +++ b/after/plugin/treesitter.lua @@ -0,0 +1,5 @@ +require('nvim-treesitter.configs').setup { + -- Add languages to be installed here that you want installed for treesitter + ensure_installed = {'terraform'}, + auto_install = true +} diff --git a/init.lua b/init.lua index 88820d62..c3ce5ee2 100644 --- a/init.lua +++ b/init.lua @@ -389,7 +389,7 @@ local on_attach = function(_, bufnr) -- See `:help K` for why this keymap nmap('K', vim.lsp.buf.hover, 'Hover Documentation') - nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') + -- nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') -- Lesser used LSP functionality nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index d6e52fbb..2a533afb 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -4,4 +4,5 @@ -- See the kickstart.nvim README for more information return { 'fatih/vim-go', + 'mbbill/undotree' } diff --git a/lua/custom/plugins/lsp_signature.lua b/lua/custom/plugins/lsp_signature.lua new file mode 100644 index 00000000..479d6677 --- /dev/null +++ b/lua/custom/plugins/lsp_signature.lua @@ -0,0 +1,6 @@ +return { + 'ray-x/lsp_signature.nvim', + config = function() + require('lsp_signature').setup {} + end +} \ No newline at end of file