From ce4dbe68fc4245426f7bfb2ccc43b20e5c2c9ced Mon Sep 17 00:00:00 2001 From: juancwu <46619361+juancwu@users.noreply.github.com> Date: Thu, 5 Jan 2023 18:57:59 -0500 Subject: [PATCH 01/19] update: remove unity-projects dir for wsl2 --- .config/fish/functions/peco_change_directory.fish | 2 -- 1 file changed, 2 deletions(-) diff --git a/.config/fish/functions/peco_change_directory.fish b/.config/fish/functions/peco_change_directory.fish index 0da1f36..ec1a5cd 100644 --- a/.config/fish/functions/peco_change_directory.fish +++ b/.config/fish/functions/peco_change_directory.fish @@ -19,8 +19,6 @@ function peco_change_directory # ghq list -p # gh cli replaced this, so it is no longer needed # list local repositories find $HOME/ghq -mindepth 2 -maxdepth 2 -type d - # list unity projects - find $HOME/unity-projects -mindepth 1 -maxdepth 1 -type d # home directory ls -ad $HOME/*/ | grep -v \.git # current directory From 1382c7135f8834b597ba33e626408eb3f93eb0be Mon Sep 17 00:00:00 2001 From: juancwu <46619361+juancwu@users.noreply.github.com> Date: Mon, 9 Jan 2023 23:05:11 -0500 Subject: [PATCH 02/19] update: add new 'onedark' theme for neovim --- .config/nvim/after/plugin/lualine.rc.lua | 2 +- .config/nvim/after/plugin/onedark.rc.lua | 13 +++++++++++++ .config/nvim/lua/juancwu/packer.lua | 3 ++- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 .config/nvim/after/plugin/onedark.rc.lua diff --git a/.config/nvim/after/plugin/lualine.rc.lua b/.config/nvim/after/plugin/lualine.rc.lua index 67839ef..e779c8a 100644 --- a/.config/nvim/after/plugin/lualine.rc.lua +++ b/.config/nvim/after/plugin/lualine.rc.lua @@ -5,7 +5,7 @@ if (not status) then return end lualine.setup { options = { icons_enabled = true, - theme = 'solarized_dark', + theme = 'onedark', section_separators = { left = '', right = '' diff --git a/.config/nvim/after/plugin/onedark.rc.lua b/.config/nvim/after/plugin/onedark.rc.lua new file mode 100644 index 0000000..04903b3 --- /dev/null +++ b/.config/nvim/after/plugin/onedark.rc.lua @@ -0,0 +1,13 @@ +local status, onedark = pcall(require, 'onedark') + +if not status then return end + +onedark.setup { + style = 'dark', + transparent = true, + lualine = { + transparent = true, -- Set to true when using 'onedark' theme + } +} + +onedark.load() diff --git a/.config/nvim/lua/juancwu/packer.lua b/.config/nvim/lua/juancwu/packer.lua index f5fe94b..e2ec1d7 100644 --- a/.config/nvim/lua/juancwu/packer.lua +++ b/.config/nvim/lua/juancwu/packer.lua @@ -18,7 +18,8 @@ return require('packer').startup(function(use) -- colorscheme use "tjdevries/colorbuddy.nvim" - use "svrana/neosolarized.nvim" +-- use "svrana/neosolarized.nvim" + use "navarasu/onedark.nvim" -- treesitter baby use('nvim-treesitter/nvim-treesitter', { run = ':TSUpdate' }) From 76152e4132990308a532f52e2f30a4252e186f77 Mon Sep 17 00:00:00 2001 From: juancwu <46619361+juancwu@users.noreply.github.com> Date: Tue, 17 Jan 2023 16:07:19 -0500 Subject: [PATCH 03/19] update: add new plugin 'null-ls' --- .config/nvim/lua/juancwu/packer.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.config/nvim/lua/juancwu/packer.lua b/.config/nvim/lua/juancwu/packer.lua index e2ec1d7..e1bf424 100644 --- a/.config/nvim/lua/juancwu/packer.lua +++ b/.config/nvim/lua/juancwu/packer.lua @@ -54,6 +54,14 @@ return require('packer').startup(function(use) } } + -- Formatter configuration using null-ls + use { + 'jose-elias-alvarez/null-ls.nvim', + requires = { + 'nvim-lua/plenary.nvim' + } + } + -- status line use { 'nvim-lualine/lualine.nvim', @@ -80,4 +88,7 @@ return require('packer').startup(function(use) -- auto closing tags use "windwp/nvim-ts-autotag" + + -- python indentation + use "Vimjas/vim-python-pep8-indent" end) From 6c23ba8ea3b7b9dceedd4666846ca6c3ec10c57b Mon Sep 17 00:00:00 2001 From: juancwu <46619361+juancwu@users.noreply.github.com> Date: Tue, 17 Jan 2023 16:07:47 -0500 Subject: [PATCH 04/19] add: setup file for null-ls --- .config/nvim/after/plugin/null-ls.rc.lua | 42 ++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .config/nvim/after/plugin/null-ls.rc.lua diff --git a/.config/nvim/after/plugin/null-ls.rc.lua b/.config/nvim/after/plugin/null-ls.rc.lua new file mode 100644 index 0000000..549834c --- /dev/null +++ b/.config/nvim/after/plugin/null-ls.rc.lua @@ -0,0 +1,42 @@ +local status, null_ls = pcall(require, "null-ls") +if not status then + return +end + +local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) + +local lsp_formatting = function(bufnr) + vim.lsp.buf.format({ + filter = function(client) + return client.name == "null-ls" + end, + bufnr = bufnr, + }) +end + +null_ls.setup({ + sources = { + null_ls.builtins.formatting.prettierd, + null_ls.builtins.formatting.autopep8, + null_ls.builtins.formatting.stylua, + }, + on_attach = function(client, bufnr) + if client.supports_method("textDocument/formatting") then + vim.api.nvim_clear_autocmds({ + group = augroup, + buffer = bufnr, + }) + vim.api.nvim_create_autocmd("BufWritePre", { + group = augroup, + buffer = bufnr, + callback = function() + lsp_formatting(bufnr) + end, + }) + end + end, +}) + +vim.api.nvim_create_user_command("DisableLspFormatting", function() + vim.api.nvim_clear_autocmds({ group = augroup, buffer = 0 }) +end, { nargs = 0 }) From 21b0ffbe5b0d1e2ceb2ebf7db0a1ba30c550cad9 Mon Sep 17 00:00:00 2001 From: juancwu <46619361+juancwu@users.noreply.github.com> Date: Tue, 17 Jan 2023 16:08:07 -0500 Subject: [PATCH 05/19] add: setup file for pythonpep8 --- .config/nvim/after/plugin/pythonpep8.rc.lua | 1 + 1 file changed, 1 insertion(+) create mode 100644 .config/nvim/after/plugin/pythonpep8.rc.lua diff --git a/.config/nvim/after/plugin/pythonpep8.rc.lua b/.config/nvim/after/plugin/pythonpep8.rc.lua new file mode 100644 index 0000000..b0cce28 --- /dev/null +++ b/.config/nvim/after/plugin/pythonpep8.rc.lua @@ -0,0 +1 @@ +vim.g.python_pep8_indent_hang_closing = 1 -- format multiline lists and dictionaries, and more From 9b4c4dcd10abc515da485d712bd4fa3d038e317b Mon Sep 17 00:00:00 2001 From: juancwu <46619361+juancwu@users.noreply.github.com> Date: Wed, 8 Feb 2023 18:47:07 -0500 Subject: [PATCH 06/19] add nvm to wsl/linux config --- .config/fish/config.fish | 11 +++++++++++ .config/nvm/nvmrc | 1 + 2 files changed, 12 insertions(+) create mode 100644 .config/nvm/nvmrc diff --git a/.config/fish/config.fish b/.config/fish/config.fish index 1810b52..a2f9b59 100644 --- a/.config/fish/config.fish +++ b/.config/fish/config.fish @@ -49,6 +49,17 @@ if type -q tmux alias tmks "tmux kill-session" end +if type -q nvm + nvm use >/dev/null +end + +function fish_greeting + echo "Welcome Back Juan!" + if type -q nvm + echo "Current Node:$(nvm current)" + end +end + # allow local config overwrite set LOCAL_CONFIG (dirname (status --current-file))/config-local.fish if test -f $LOCAL_CONFIG diff --git a/.config/nvm/nvmrc b/.config/nvm/nvmrc new file mode 100644 index 0000000..b6a7d89 --- /dev/null +++ b/.config/nvm/nvmrc @@ -0,0 +1 @@ +16 From 99052bb81ed34e4ae3993db3fe5d2508f1cb11dd Mon Sep 17 00:00:00 2001 From: juancwu <46619361+juancwu@users.noreply.github.com> Date: Mon, 13 Feb 2023 22:12:53 -0500 Subject: [PATCH 07/19] configure pnpm --- .config/fish/config.fish | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.config/fish/config.fish b/.config/fish/config.fish index a2f9b59..ffc3c6b 100644 --- a/.config/fish/config.fish +++ b/.config/fish/config.fish @@ -65,3 +65,8 @@ set LOCAL_CONFIG (dirname (status --current-file))/config-local.fish if test -f $LOCAL_CONFIG source $LOCAL_CONFIG end + +# pnpm +set -gx PNPM_HOME "/home/jc/.local/share/pnpm" +set -gx PATH "$PNPM_HOME" $PATH +# pnpm end \ No newline at end of file From a9be9c49f452877695a08e2ca3f67ec5628e4b9d Mon Sep 17 00:00:00 2001 From: juancwu <46619361+juancwu@users.noreply.github.com> Date: Mon, 13 Feb 2023 22:06:27 -0500 Subject: [PATCH 08/19] update: base index for window starts from 1 --- .config/tmux/tmux.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.config/tmux/tmux.conf b/.config/tmux/tmux.conf index 27e424a..d0dfc1f 100644 --- a/.config/tmux/tmux.conf +++ b/.config/tmux/tmux.conf @@ -86,6 +86,8 @@ set-window-option -g clock-mode-colour colour64 # gree set -g set-titles on set -g set-titles-string "#T" +# start window indexing from 1 instead of 0 +set -g base-index 1 ## Imports From 0ad9275568087111a3a59b4218e54e8834b7e7a0 Mon Sep 17 00:00:00 2001 From: juancwu <46619361+juancwu@users.noreply.github.com> Date: Sun, 26 Feb 2023 20:54:53 -0500 Subject: [PATCH 09/19] some configurations --- .config/nvim/after/plugin/treesitter.rc.lua | 5 +++++ .config/tmux/plugin.conf | 1 + 2 files changed, 6 insertions(+) diff --git a/.config/nvim/after/plugin/treesitter.rc.lua b/.config/nvim/after/plugin/treesitter.rc.lua index 60ca88f..820b463 100644 --- a/.config/nvim/after/plugin/treesitter.rc.lua +++ b/.config/nvim/after/plugin/treesitter.rc.lua @@ -17,4 +17,9 @@ treesitter.setup { -- `false` will disable the whole extension enable = true, }, + + indent = { + enable = true, + disable = { "python" } + } } diff --git a/.config/tmux/plugin.conf b/.config/tmux/plugin.conf index bd89a82..6d367ee 100644 --- a/.config/tmux/plugin.conf +++ b/.config/tmux/plugin.conf @@ -5,6 +5,7 @@ set -g @plugin 'tmux-plugins/tpm' # ctrl-s -> save # ctrl-r -> restore set -g @plugin 'tmux-plugins/tmux-resurrect' +set -g @plugin 'tmux-plugins/tmux-open' # init tmux plugin manager run '~/.tmux/plugins/tpm/tpm' From d6413ee090840a4e0bac02f554561e9afd4dfe25 Mon Sep 17 00:00:00 2001 From: juancwu <46619361+juancwu@users.noreply.github.com> Date: Wed, 25 Jan 2023 20:16:04 -0500 Subject: [PATCH 10/19] add: command to quickly connect to mpi cluster --- .config/fish/functions/mpiconnect.fish | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .config/fish/functions/mpiconnect.fish diff --git a/.config/fish/functions/mpiconnect.fish b/.config/fish/functions/mpiconnect.fish new file mode 100644 index 0000000..0ee48ea --- /dev/null +++ b/.config/fish/functions/mpiconnect.fish @@ -0,0 +1,3 @@ +function mpiconnect + ssh -Y lcl_uotwlus2341@teach.scinet.utoronto.ca +end From 11599d81a3ce3b138fe16ffcdb8f70e68f12ee03 Mon Sep 17 00:00:00 2001 From: juancwu <46619361+juancwu@users.noreply.github.com> Date: Wed, 28 Jun 2023 19:47:28 -0400 Subject: [PATCH 11/19] some changes that i dont remember doing --- .config/fish/conf.d/tide.fish | 21 +++++++++++++++++++++ .config/nvim/lua/juancwu/options.lua | 6 +++--- 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 .config/fish/conf.d/tide.fish diff --git a/.config/fish/conf.d/tide.fish b/.config/fish/conf.d/tide.fish new file mode 100644 index 0000000..3a2410f --- /dev/null +++ b/.config/fish/conf.d/tide.fish @@ -0,0 +1,21 @@ +set -g tide_git_bg_color 268bd2 +set -g tide_git_bg_color_unstable C4A000 +set -g tide_git_bg_color_urgent CC0000 +set -g tide_git_branch_color 000000 +set -g tide_git_color_branch 000000 +set -g tide_git_color_conflicted 000000 +set -g tide_git_color_dirty 000000 +set -g tide_git_color_operation 000000 +set -g tide_git_color_staged 000000 +set -g tide_git_color_stash 000000 +set -g tide_git_color_untracked 000000 +set -g tide_git_color_upstream 000000 +set -g tide_git_conflicted_color 000000 +set -g tide_git_dirty_color 000000 +set -g tide_git_icon  +set -g tide_git_operation_color 000000 +set -g tide_git_staged_color 000000 +set -g tide_git_stash_color 000000 +set -g tide_git_untracked_color 000000 +set -g tide_git_upstream_color 000000 +set -g tide_pwd_bg_color 444444 diff --git a/.config/nvim/lua/juancwu/options.lua b/.config/nvim/lua/juancwu/options.lua index 87f4dc7..54f2fdc 100644 --- a/.config/nvim/lua/juancwu/options.lua +++ b/.config/nvim/lua/juancwu/options.lua @@ -7,9 +7,9 @@ vim.opt.relativenumber = true -- juicy relativity vim.opt.autoindent = true vim.opt.smartindent = true -vim.opt.tabstop = 4 -vim.opt.softtabstop = 4 -vim.opt.shiftwidth = 4 +vim.opt.tabstop = 2 +vim.opt.softtabstop = 2 +vim.opt.shiftwidth = 2 vim.opt.expandtab = true vim.opt.smarttab = true vim.opt.breakindent = true From 108c9c97d5465037992a9a09afd38c2c01bf7be6 Mon Sep 17 00:00:00 2001 From: juancwu <46619361+juancwu@users.noreply.github.com> Date: Sun, 2 Jul 2023 20:19:21 -0400 Subject: [PATCH 12/19] new config for wsl2 --- .config/fish/config-linux.fish | 10 +- .config/nvim/after/plugin/autopairs.rc.lua | 7 -- .config/nvim/after/plugin/autotags.rc.lua | 5 - .config/nvim/after/plugin/colorizer.rc.lua | 9 -- .config/nvim/after/plugin/fugitive.rc.lua | 27 ----- .config/nvim/after/plugin/harpoon.rc.lua | 17 --- .config/nvim/after/plugin/lsp.rc.lua | 10 -- .config/nvim/after/plugin/lspzero.rc.lua | 12 ++ .config/nvim/after/plugin/lualine.rc.lua | 53 --------- .config/nvim/after/plugin/markdown.rc.lua | 18 --- .config/nvim/after/plugin/neosolarized.rc.lua | 31 ----- .config/nvim/after/plugin/null-ls.rc.lua | 42 ------- .config/nvim/after/plugin/onedark.rc.lua | 13 -- .config/nvim/after/plugin/pythonpep8.rc.lua | 1 - .config/nvim/after/plugin/telescope.rc.lua | 63 ---------- .config/nvim/after/plugin/treesitter.rc.lua | 25 ---- .config/nvim/after/plugin/undotree.rc.lua | 18 --- .config/nvim/after/plugin/zenmode.rc.lua | 7 -- .config/nvim/lua/juancwu/clipboard.lua | 12 ++ .config/nvim/lua/juancwu/init.lua | 2 + .config/nvim/lua/juancwu/keymaps.lua | 8 +- .config/nvim/lua/juancwu/options.lua | 6 +- .config/nvim/lua/juancwu/packer.lua | 112 ++++-------------- .config/nvim/lua/juancwu/theme.lua | 1 + 24 files changed, 62 insertions(+), 447 deletions(-) delete mode 100644 .config/nvim/after/plugin/autopairs.rc.lua delete mode 100644 .config/nvim/after/plugin/autotags.rc.lua delete mode 100644 .config/nvim/after/plugin/colorizer.rc.lua delete mode 100644 .config/nvim/after/plugin/fugitive.rc.lua delete mode 100644 .config/nvim/after/plugin/harpoon.rc.lua delete mode 100644 .config/nvim/after/plugin/lsp.rc.lua create mode 100644 .config/nvim/after/plugin/lspzero.rc.lua delete mode 100644 .config/nvim/after/plugin/lualine.rc.lua delete mode 100644 .config/nvim/after/plugin/markdown.rc.lua delete mode 100644 .config/nvim/after/plugin/neosolarized.rc.lua delete mode 100644 .config/nvim/after/plugin/null-ls.rc.lua delete mode 100644 .config/nvim/after/plugin/onedark.rc.lua delete mode 100644 .config/nvim/after/plugin/pythonpep8.rc.lua delete mode 100644 .config/nvim/after/plugin/telescope.rc.lua delete mode 100644 .config/nvim/after/plugin/treesitter.rc.lua delete mode 100644 .config/nvim/after/plugin/undotree.rc.lua delete mode 100644 .config/nvim/after/plugin/zenmode.rc.lua create mode 100644 .config/nvim/lua/juancwu/clipboard.lua create mode 100644 .config/nvim/lua/juancwu/theme.lua diff --git a/.config/fish/config-linux.fish b/.config/fish/config-linux.fish index b6e7a02..c9a5556 100644 --- a/.config/fish/config-linux.fish +++ b/.config/fish/config-linux.fish @@ -1,6 +1,6 @@ #x-server -set -g DISPLAY $(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0 - -if test -x (command -v npiperelay.exe) - source (dirname (status --current-file))/config-npiperelay.fish -end +#set -g DISPLAY $(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0 +# +#if test -x (command -v npiperelay.exe) +# source (dirname (status --current-file))/config-npiperelay.fish +#end diff --git a/.config/nvim/after/plugin/autopairs.rc.lua b/.config/nvim/after/plugin/autopairs.rc.lua deleted file mode 100644 index 4cbbd59..0000000 --- a/.config/nvim/after/plugin/autopairs.rc.lua +++ /dev/null @@ -1,7 +0,0 @@ -local status, autopairs = pcall(require, "nvim-autopairs") - -if not status then return end - -autopairs.setup({ - disable_filetype = { "TelescopePrompt", "vim" } -}) diff --git a/.config/nvim/after/plugin/autotags.rc.lua b/.config/nvim/after/plugin/autotags.rc.lua deleted file mode 100644 index 4b339e4..0000000 --- a/.config/nvim/after/plugin/autotags.rc.lua +++ /dev/null @@ -1,5 +0,0 @@ -local status, autotag = pcall(require, "nvim-ts-autotag") - -if not status then return end - -autotag.setup() diff --git a/.config/nvim/after/plugin/colorizer.rc.lua b/.config/nvim/after/plugin/colorizer.rc.lua deleted file mode 100644 index 1cebf70..0000000 --- a/.config/nvim/after/plugin/colorizer.rc.lua +++ /dev/null @@ -1,9 +0,0 @@ -local status, colorizer = pcall(require, 'colorizer') - -if not status then return end - -colorizer.setup({ - '*'; -}) - - diff --git a/.config/nvim/after/plugin/fugitive.rc.lua b/.config/nvim/after/plugin/fugitive.rc.lua deleted file mode 100644 index bc4d194..0000000 --- a/.config/nvim/after/plugin/fugitive.rc.lua +++ /dev/null @@ -1,27 +0,0 @@ -vim.keymap.set("n", "gs", vim.cmd.Git) - -local juancwu_fugitive = vim.api.nvim_create_augroup("juancwu_fugitive", {}) - -vim.api.nvim_create_autocmd("BufWinEnter", { - group = juancwu_fugitive, - pattern = "*", - callback = function() - if vim.bo.ft ~= "fugitive" then - return - end - - local bufnr = vim.api.nvim_get_current_buf() - local opts = { buffer = bufnr, remap = false } - - vim.keymap.set("n", "p", function () - vim.cmd.Git("push") - end, opts) - - vim.keymap.set("n", "P", function () - vim.cmd.Git({"pull", "--rebase"}) - end, opts) - - -- setup an upstream for first pushes to a branch - vim.keymap.set("n", "u", ":Git push -u origin ", opts) - end -}) diff --git a/.config/nvim/after/plugin/harpoon.rc.lua b/.config/nvim/after/plugin/harpoon.rc.lua deleted file mode 100644 index 150cdca..0000000 --- a/.config/nvim/after/plugin/harpoon.rc.lua +++ /dev/null @@ -1,17 +0,0 @@ -local status, mark = pcall(require, "harpoon.mark") - -if not status then return end - -local status, ui = pcall(require, "harpoon.ui") - -if not status then return end - -vim.keymap.set("n", "a", mark.add_file) -vim.keymap.set("n", "", ui.toggle_quick_menu) - -vim.keymap.set("n", "q", function() ui.nav_file(1) end) -vim.keymap.set("n", "w", function() ui.nav_file(2) end) -vim.keymap.set("n", "e", function() ui.nav_file(3) end) -vim.keymap.set("n", "r", function() ui.nav_file(4) end) -vim.keymap.set("n", ",", ui.nav_prev) -vim.keymap.set("n", ".", ui.nav_next) diff --git a/.config/nvim/after/plugin/lsp.rc.lua b/.config/nvim/after/plugin/lsp.rc.lua deleted file mode 100644 index ac23c43..0000000 --- a/.config/nvim/after/plugin/lsp.rc.lua +++ /dev/null @@ -1,10 +0,0 @@ -local status, lsp = pcall(require, "lsp-zero") - -if not status then return end - -lsp.preset("recommended") -lsp.setup() - -lsp.on_attach(function(_, buffnr) - vim.keymap.set("n", "", vim.lsp.buf.signature_help, { buffer = buffnr }) -end) diff --git a/.config/nvim/after/plugin/lspzero.rc.lua b/.config/nvim/after/plugin/lspzero.rc.lua new file mode 100644 index 0000000..e1c27a5 --- /dev/null +++ b/.config/nvim/after/plugin/lspzero.rc.lua @@ -0,0 +1,12 @@ +local status, lspzero = pcall(require, "lsp-zero") + +if not status then return end + +lspzero.preset("recommended") + +-- first argument is the client +lspzero.on_attach(function(_, bufnr) + lspzero.default_keymaps({buffer = bufnr}) +end) + +lspzero.setup() diff --git a/.config/nvim/after/plugin/lualine.rc.lua b/.config/nvim/after/plugin/lualine.rc.lua deleted file mode 100644 index e779c8a..0000000 --- a/.config/nvim/after/plugin/lualine.rc.lua +++ /dev/null @@ -1,53 +0,0 @@ -local status, lualine = pcall(require, 'lualine') - -if (not status) then return end - -lualine.setup { - options = { - icons_enabled = true, - theme = 'onedark', - section_separators = { - left = '', - right = '' - }, - component_separators = { - left = '', - right = '' - }, - disabled_filetypes = {} - }, - sections = { - lualine_a = { 'mode' }, - lualine_b = { 'branch' }, - lualine_c = { { - 'filename', - file_status = true, -- display file status - path = 0 -- no file path - } }, - lualine_x = { - { - 'diagnostics', - sources = { 'nvim_diagnostic' }, - symbols = { error = ' ', warn = ' ', info = ' ', hint = '' } - }, - 'enconding', - 'filetype' - }, - lualine_y = { 'progress' }, - lualine_z = { 'location' } - }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = { { - 'filename', - file_status = true, - path = 1 - } }, - lualine_x = { 'location' }, - lualine_y = {}, - lualine_z = {} - }, - tabline = {}, - extensions = { 'fugitive' } -} diff --git a/.config/nvim/after/plugin/markdown.rc.lua b/.config/nvim/after/plugin/markdown.rc.lua deleted file mode 100644 index 10032cb..0000000 --- a/.config/nvim/after/plugin/markdown.rc.lua +++ /dev/null @@ -1,18 +0,0 @@ -local juancwu_markdown = vim.api.nvim_create_augroup("juancwu_markdown", {}) - -vim.api.nvim_create_autocmd("BufWinEnter", { - group = juancwu_markdown, - pattern = "*", - callback = function() - if vim.bo.ft ~= "markdown" then - return - end - - local bufnr = vim.api.nvim_get_current_buf() - local opts = { buffer = bufnr, remap = false } - - vim.keymap.set("n", "p", vim.cmd.MarkdownPreview, opts) - vim.keymap.set("n", "s", vim.cmd.MarkdownPreviewStop, opts) - vim.keymap.set("n", "t", vim.cmd.MarkdownPreviewToggle, opts) - end -}) diff --git a/.config/nvim/after/plugin/neosolarized.rc.lua b/.config/nvim/after/plugin/neosolarized.rc.lua deleted file mode 100644 index 712e007..0000000 --- a/.config/nvim/after/plugin/neosolarized.rc.lua +++ /dev/null @@ -1,31 +0,0 @@ -local status, n = pcall(require, "neosolarized") - -if not status then return end - -n.setup({ comment_italics = true }) - -local cb = require("colorbuddy.init") -local Color = cb.Color -local colors = cb.colors -local Group = cb.Group -local groups = cb.groups -local styles = cb.styles - -Color.new("black", "#000000") -Group.new("CursorLine", colors.none, colors.base03, styles.NONE, colors.base1) -Group.new("CursorLineNr", colors.yellow, colors.black, styles.NONE, colors.base1) -Group.new("Visual", colors.none, colors.base03, styles.reverse) - --- local cError = groups.Error.fg --- local cInfo = groups.Information.fg --- local cWarn = groups.Warning.fg --- local cHint = groups.Hint.fg - --- Group.new("DiagnosticVirtualTextError", cError, cError:dark():dark():dark():dark(), styles.NONE) --- Group.new("DiagnosticVirtualTextInfo", cInfo, cInfo:dark():dark():dark(), styles.NONE) --- Group.new("DiagnosticVirtualTextWarn", cWarn, cWarn:dark():dark():dark(), styles.NONE) --- Group.new("DiagnosticVirtualTextHint", cHint, cHint:dark():dark():dark(), styles.NONE) --- Group.new("DiagnosticUnderlineError", colors.none, colors.none, styles.udnercurl, cError) --- Group.new("DiagnosticUnderlineWarn", colors.none, colors.none, styles.udnercurl, cWarn) --- Group.new("DiagnosticUnderlineInfo", colors.none, colors.none, styles.udnercurl, cInfo) --- Group.new("DiagnosticUnderlineHint", colors.none, colors.none, styles.udnercurl, cHint) diff --git a/.config/nvim/after/plugin/null-ls.rc.lua b/.config/nvim/after/plugin/null-ls.rc.lua deleted file mode 100644 index 549834c..0000000 --- a/.config/nvim/after/plugin/null-ls.rc.lua +++ /dev/null @@ -1,42 +0,0 @@ -local status, null_ls = pcall(require, "null-ls") -if not status then - return -end - -local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) - -local lsp_formatting = function(bufnr) - vim.lsp.buf.format({ - filter = function(client) - return client.name == "null-ls" - end, - bufnr = bufnr, - }) -end - -null_ls.setup({ - sources = { - null_ls.builtins.formatting.prettierd, - null_ls.builtins.formatting.autopep8, - null_ls.builtins.formatting.stylua, - }, - on_attach = function(client, bufnr) - if client.supports_method("textDocument/formatting") then - vim.api.nvim_clear_autocmds({ - group = augroup, - buffer = bufnr, - }) - vim.api.nvim_create_autocmd("BufWritePre", { - group = augroup, - buffer = bufnr, - callback = function() - lsp_formatting(bufnr) - end, - }) - end - end, -}) - -vim.api.nvim_create_user_command("DisableLspFormatting", function() - vim.api.nvim_clear_autocmds({ group = augroup, buffer = 0 }) -end, { nargs = 0 }) diff --git a/.config/nvim/after/plugin/onedark.rc.lua b/.config/nvim/after/plugin/onedark.rc.lua deleted file mode 100644 index 04903b3..0000000 --- a/.config/nvim/after/plugin/onedark.rc.lua +++ /dev/null @@ -1,13 +0,0 @@ -local status, onedark = pcall(require, 'onedark') - -if not status then return end - -onedark.setup { - style = 'dark', - transparent = true, - lualine = { - transparent = true, -- Set to true when using 'onedark' theme - } -} - -onedark.load() diff --git a/.config/nvim/after/plugin/pythonpep8.rc.lua b/.config/nvim/after/plugin/pythonpep8.rc.lua deleted file mode 100644 index b0cce28..0000000 --- a/.config/nvim/after/plugin/pythonpep8.rc.lua +++ /dev/null @@ -1 +0,0 @@ -vim.g.python_pep8_indent_hang_closing = 1 -- format multiline lists and dictionaries, and more diff --git a/.config/nvim/after/plugin/telescope.rc.lua b/.config/nvim/after/plugin/telescope.rc.lua deleted file mode 100644 index 4733fe9..0000000 --- a/.config/nvim/after/plugin/telescope.rc.lua +++ /dev/null @@ -1,63 +0,0 @@ -local status, telescope = pcall(require, "telescope") - -if not status then return end - -local actions = require("telescope.actions") -local builtin = require("telescope.builtin") - -local fb_actions = require "telescope".extensions.file_browser.actions - -local function telescope_buffer_dir() - return vim.fn.expand("%:p:h") -end - -telescope.setup({ - defaults = { - mappings = { - n = { - ['q'] = actions.close - } - } - }, - extensions = { - file_browser = { - theme = "dropdown", - hijack_netrw = true, - hidden = true, - mappings = { - ['i'] = { - [''] = function() vim.cmd("normal vbd") end - }, - ['n'] = { - ['N'] = fb_actions.create, - ['h'] = fb_actions.goto_parent_dir, - ['/'] = function() vim.cmd("startinsert") end, - ['D'] = fb_actions.remove - } - } - } - } -}) - -telescope.load_extension("file_browser") - - --- Set up keymaps specific to telescope -vim.keymap.set("n", ";f", function() - builtin.find_files({ no_ignore = false, hidden = true }) -end) -vim.keymap.set("n", ";g", builtin.git_files) -vim.keymap.set("n", "sf", - function() - telescope.extensions.file_browser.file_browser({ - path = "%:p:h", - cwd = telescope_buffer_dir(), - respect_gitignore = true, - hidden = true, - grouped = true, - previewer = false, - initial_mode = "normal", - layout_config = { height = 40 } - }) - end) -vim.keymap.set("n", ";h", builtin.help_tags) diff --git a/.config/nvim/after/plugin/treesitter.rc.lua b/.config/nvim/after/plugin/treesitter.rc.lua deleted file mode 100644 index 820b463..0000000 --- a/.config/nvim/after/plugin/treesitter.rc.lua +++ /dev/null @@ -1,25 +0,0 @@ -local status, treesitter = pcall(require, "nvim-treesitter.configs") - -if not status then return end - -treesitter.setup { - -- A list of parser names, or "all" - ensure_installed = { "help", "javascript", "typescript", "c", "lua", "rust" }, - - -- Install parsers synchronously (only applied to `ensure_installed`) - sync_install = false, - - -- Automatically install missing parsers when entering buffer - -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally - auto_install = true, - - highlight = { - -- `false` will disable the whole extension - enable = true, - }, - - indent = { - enable = true, - disable = { "python" } - } -} diff --git a/.config/nvim/after/plugin/undotree.rc.lua b/.config/nvim/after/plugin/undotree.rc.lua deleted file mode 100644 index 4c68566..0000000 --- a/.config/nvim/after/plugin/undotree.rc.lua +++ /dev/null @@ -1,18 +0,0 @@ -vim.keymap.set("n", "u", vim.cmd.UndotreeToggle) - -local has_persistent_undo = vim.api.nvim_call_function("has", { "persistent_undo" }) - -if has_persistent_undo then - local target_path = vim.api.nvim_call_function("expand", { "~/.undodir" }) - - local is_directory = vim.api.nvim_call_function("isdirectory", { target_path }) - - if not is_directory then - vim.api.nvim_call_function("mkdir", { target_path, "p", 0700 }) - end - - vim.opt.undodir = target_path - vim.opt.undofile = true -end - - diff --git a/.config/nvim/after/plugin/zenmode.rc.lua b/.config/nvim/after/plugin/zenmode.rc.lua deleted file mode 100644 index 9ed8476..0000000 --- a/.config/nvim/after/plugin/zenmode.rc.lua +++ /dev/null @@ -1,7 +0,0 @@ -local status, zen = pcall(require, "zen-mode") - -if not status then return end - -zen.setup {} - -vim.keymap.set("n", "o", vim.cmd.ZenMode, { silent = true }) diff --git a/.config/nvim/lua/juancwu/clipboard.lua b/.config/nvim/lua/juancwu/clipboard.lua new file mode 100644 index 0000000..9c3eb14 --- /dev/null +++ b/.config/nvim/lua/juancwu/clipboard.lua @@ -0,0 +1,12 @@ +vim.g.clipboard = { + name = "win32yank", + copy = { + ['+'] = "win32yank.exe -i --crlf", + ['*'] = "win32yank.exe -i --crlf", + }, + paste = { + ['+'] = "win32yank.exe -o --lf", + ['*'] = "win32yank.exe -o --lf", + }, + cache_enabled = 0, +} diff --git a/.config/nvim/lua/juancwu/init.lua b/.config/nvim/lua/juancwu/init.lua index aaa3442..84f29a6 100644 --- a/.config/nvim/lua/juancwu/init.lua +++ b/.config/nvim/lua/juancwu/init.lua @@ -1,2 +1,4 @@ require("juancwu.keymaps") require("juancwu.options") +require("juancwu.theme") +require("juancwu.clipboard") diff --git a/.config/nvim/lua/juancwu/keymaps.lua b/.config/nvim/lua/juancwu/keymaps.lua index 3a1e5c0..a3cadb8 100644 --- a/.config/nvim/lua/juancwu/keymaps.lua +++ b/.config/nvim/lua/juancwu/keymaps.lua @@ -1,7 +1,7 @@ vim.g.mapleader = " " -- open the explorer -vim.keymap.set("n", "pv", "Ex") +vim.keymap.set("n", "e", "Ex") -- move highlighted lines vim.keymap.set("v", "J", ":m '>+1gv=gv") @@ -18,9 +18,6 @@ vim.keymap.set("n", "", "zz") vim.keymap.set("n", "n", "nzzzv") vim.keymap.set("n", "N", "Nzzzv") --- paste without losing clipboard -vim.keymap.set("x", "p", "\"_dP") - -- do not copy with x, for god sake, WHY copy something that is being deleted?? vim.keymap.set("n", "x", "\"_x") @@ -36,8 +33,7 @@ vim.keymap.set("n", "dd", "dd") -- cut line, under my control -- copy/paste to/from system clipboard vim.keymap.set({"n", "v"}, "y", "\"+y") -vim.keymap.set("n", "Y", "\"+Y") -vim.keymap.set({"n", "v"}, "P", "\"+p") +vim.keymap.set({"n", "v"}, "p", "\"+p") -- increment/decrement a count, helpful for changing indeces vim.keymap.set("n", "+", "") diff --git a/.config/nvim/lua/juancwu/options.lua b/.config/nvim/lua/juancwu/options.lua index 54f2fdc..87f4dc7 100644 --- a/.config/nvim/lua/juancwu/options.lua +++ b/.config/nvim/lua/juancwu/options.lua @@ -7,9 +7,9 @@ vim.opt.relativenumber = true -- juicy relativity vim.opt.autoindent = true vim.opt.smartindent = true -vim.opt.tabstop = 2 -vim.opt.softtabstop = 2 -vim.opt.shiftwidth = 2 +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 vim.opt.expandtab = true vim.opt.smarttab = true vim.opt.breakindent = true diff --git a/.config/nvim/lua/juancwu/packer.lua b/.config/nvim/lua/juancwu/packer.lua index e1bf424..3fbc948 100644 --- a/.config/nvim/lua/juancwu/packer.lua +++ b/.config/nvim/lua/juancwu/packer.lua @@ -1,94 +1,32 @@ --- This file can be loaded by calling `lua require('plugins')` from your init.vim - -- Only required if you have packer configured as `opt` vim.cmd [[packadd packer.nvim]] return require('packer').startup(function(use) - -- Packer can manage itself - use 'wbthomason/packer.nvim' + -- Packer can manage itself + use 'wbthomason/packer.nvim' - -- fuzzy finder - use 'nvim-lua/plenary.nvim' - use { - 'nvim-telescope/telescope.nvim', tag = '0.1.0', - requires = { {'nvim-lua/plenary.nvim'} } + -- Themes + use({ 'rose-pine/neovim', as = 'rose-pine' }) + + -- Sweet LSP + use { + 'VonHeikemen/lsp-zero.nvim', + branch = 'v2.x', + requires = { + -- LSP Support + {'neovim/nvim-lspconfig'}, -- Required + { -- Optional + 'williamboman/mason.nvim', + run = function() + pcall(vim.cmd, 'MasonUpdate') + end, + }, + {'williamboman/mason-lspconfig.nvim'}, -- Optional + + -- Autocompletion + {'hrsh7th/nvim-cmp'}, -- Required + {'hrsh7th/cmp-nvim-lsp'}, -- Required + {'L3MON4D3/LuaSnip'}, -- Required } - -- file utilities for telescope - use { "nvim-telescope/telescope-file-browser.nvim" } - - -- colorscheme - use "tjdevries/colorbuddy.nvim" --- use "svrana/neosolarized.nvim" - use "navarasu/onedark.nvim" - - -- treesitter baby - use('nvim-treesitter/nvim-treesitter', { run = ':TSUpdate' }) - - -- quick navigation between files, harpoon - use 'ThePrimeagen/harpoon' - use 'mbbill/undotree' - - -- git functionalities - use 'tpope/vim-fugitive' - - -- LSP configurations - use { - 'VonHeikemen/lsp-zero.nvim', - requires = { - -- LSP Support - {'neovim/nvim-lspconfig'}, - {'williamboman/mason.nvim'}, - {'williamboman/mason-lspconfig.nvim'}, - - -- Autocompletion - {'hrsh7th/nvim-cmp'}, - {'hrsh7th/cmp-buffer'}, - {'hrsh7th/cmp-path'}, - {'saadparwaiz1/cmp_luasnip'}, - {'hrsh7th/cmp-nvim-lsp'}, - {'hrsh7th/cmp-nvim-lua'}, - - -- Snippets - {'L3MON4D3/LuaSnip'}, - {'rafamadriz/friendly-snippets'}, - } - } - - -- Formatter configuration using null-ls - use { - 'jose-elias-alvarez/null-ls.nvim', - requires = { - 'nvim-lua/plenary.nvim' - } - } - - -- status line - use { - 'nvim-lualine/lualine.nvim', - requires = { 'kyazdani42/nvim-web-devicons', opt = true } - } - - -- autopairs, complete brackets - use { - "windwp/nvim-autopairs", - config = function() require("nvim-autopairs").setup {} end - } - - -- colorize the hex codes - use 'norcalli/nvim-colorizer.lua' - - -- markdown preview, sweet - use({ - "iamcco/markdown-preview.nvim", - run = function() vim.fn["mkdp#util#install"]() end, - }) - - -- zen mode, mmmmmm - use "folke/zen-mode.nvim" - - -- auto closing tags - use "windwp/nvim-ts-autotag" - - -- python indentation - use "Vimjas/vim-python-pep8-indent" + } end) diff --git a/.config/nvim/lua/juancwu/theme.lua b/.config/nvim/lua/juancwu/theme.lua new file mode 100644 index 0000000..3240184 --- /dev/null +++ b/.config/nvim/lua/juancwu/theme.lua @@ -0,0 +1 @@ +vim.cmd('colorscheme rose-pine') From 690ba9c9da0e269be7322ffc19bbf0906289cc78 Mon Sep 17 00:00:00 2001 From: juancwu <46619361+juancwu@users.noreply.github.com> Date: Fri, 7 Jul 2023 01:11:50 -0400 Subject: [PATCH 13/19] in progress: improving nvim workflow without system wide keybinds --- .config/nvim/after/plugin/autopairs.rc.lua | 7 ++ .config/nvim/after/plugin/autotags.rc.lua | 5 ++ .config/nvim/after/plugin/harpoon.rc.lua | 18 +++++ .config/nvim/after/plugin/lspzero.rc.lua | 35 ++++++++- .config/nvim/after/plugin/lualine.rc.lua | 52 +++++++++++++ .config/nvim/after/plugin/telescope.rc.lua | 63 ++++++++++++++++ .config/nvim/after/plugin/treesitter.rc.lua | 19 +++++ .config/nvim/after/plugin/undotree.rc.lua | 16 ++++ .config/nvim/lua/juancwu/keymaps.lua | 31 ++++++-- .config/nvim/lua/juancwu/packer.lua | 82 +++++++++++++++------ 10 files changed, 299 insertions(+), 29 deletions(-) create mode 100644 .config/nvim/after/plugin/autopairs.rc.lua create mode 100644 .config/nvim/after/plugin/autotags.rc.lua create mode 100644 .config/nvim/after/plugin/harpoon.rc.lua create mode 100644 .config/nvim/after/plugin/lualine.rc.lua create mode 100644 .config/nvim/after/plugin/telescope.rc.lua create mode 100644 .config/nvim/after/plugin/treesitter.rc.lua create mode 100644 .config/nvim/after/plugin/undotree.rc.lua diff --git a/.config/nvim/after/plugin/autopairs.rc.lua b/.config/nvim/after/plugin/autopairs.rc.lua new file mode 100644 index 0000000..995f63b --- /dev/null +++ b/.config/nvim/after/plugin/autopairs.rc.lua @@ -0,0 +1,7 @@ +local status, autopairs = pcall(require, "nvim-autopairs") + +if not status then return end + +autopairs.setup({ + disable_filetype = { "TelescopePrompt", "vim" } +}) diff --git a/.config/nvim/after/plugin/autotags.rc.lua b/.config/nvim/after/plugin/autotags.rc.lua new file mode 100644 index 0000000..4b339e4 --- /dev/null +++ b/.config/nvim/after/plugin/autotags.rc.lua @@ -0,0 +1,5 @@ +local status, autotag = pcall(require, "nvim-ts-autotag") + +if not status then return end + +autotag.setup() diff --git a/.config/nvim/after/plugin/harpoon.rc.lua b/.config/nvim/after/plugin/harpoon.rc.lua new file mode 100644 index 0000000..5ff77d5 --- /dev/null +++ b/.config/nvim/after/plugin/harpoon.rc.lua @@ -0,0 +1,18 @@ +local status, mark = pcall(require, "harpoon.mark") + +if not status then return end + +local ui +status, ui = pcall(require, "harpoon.ui") + +if not status then return end + +vim.keymap.set("n", "a", mark.add_file) +vim.keymap.set("n", "", ui.toggle_quick_menu) + +vim.keymap.set("n", "q", function() ui.nav_file(1) end) +vim.keymap.set("n", "w", function() ui.nav_file(2) end) +vim.keymap.set("n", "e", function() ui.nav_file(3) end) +vim.keymap.set("n", "r", function() ui.nav_file(4) end) +vim.keymap.set("n", ",", ui.nav_prev) +vim.keymap.set("n", ".", ui.nav_next) diff --git a/.config/nvim/after/plugin/lspzero.rc.lua b/.config/nvim/after/plugin/lspzero.rc.lua index e1c27a5..b95a5b4 100644 --- a/.config/nvim/after/plugin/lspzero.rc.lua +++ b/.config/nvim/after/plugin/lspzero.rc.lua @@ -6,7 +6,40 @@ lspzero.preset("recommended") -- first argument is the client lspzero.on_attach(function(_, bufnr) - lspzero.default_keymaps({buffer = bufnr}) + lspzero.default_keymaps({ buffer = bufnr }) + + -- custom keymaps + vim.keymap.set("n", "f", "lua vim.lsp.buf.format()") -- format buffer end) +-- Enable format on save +lspzero.format_on_save({ + format_opts = { + async = true, + timeout_ms = 10000, + }, + servers = { + ['lua_ls'] = { 'lua' }, + } +}) + +local lspconfig +status, lspconfig = pcall(require, "lspconfig") + +if status then + lspconfig.lua_ls.setup(lspzero.nvim_lua_ls()) +end + lspzero.setup() + +local cmp +status, cmp = pcall(require, 'cmp') + +if not status then return end + +cmp.setup({ + mapping = { + -- Press "Enter" to confirm completion/suggestion + [''] = cmp.mapping.confirm({ select = true }), + } +}) diff --git a/.config/nvim/after/plugin/lualine.rc.lua b/.config/nvim/after/plugin/lualine.rc.lua new file mode 100644 index 0000000..a582996 --- /dev/null +++ b/.config/nvim/after/plugin/lualine.rc.lua @@ -0,0 +1,52 @@ +local status, lualine = pcall(require, 'lualine') + +if (not status) then return end + +lualine.setup { + options = { + icons_enabled = true, + section_separators = { + left = '', + right = '' + }, + component_separators = { + left = '', + right = '' + }, + disabled_filetypes = {} + }, + sections = { + lualine_a = { 'mode' }, + lualine_b = { 'branch' }, + lualine_c = { { + 'filename', + file_status = true, -- display file status + path = 0 -- no file path + } }, + lualine_x = { + { + 'diagnostics', + sources = { 'nvim_diagnostic' }, + symbols = { error = ' ', warn = ' ', info = ' ', hint = '' } + }, + 'enconding', + 'filetype' + }, + lualine_y = { 'progress' }, + lualine_z = { 'location' } + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { { + 'filename', + file_status = true, + path = 1 + } }, + lualine_x = { 'location' }, + lualine_y = {}, + lualine_z = {} + }, + tabline = {}, + extensions = { 'fugitive' } +} diff --git a/.config/nvim/after/plugin/telescope.rc.lua b/.config/nvim/after/plugin/telescope.rc.lua new file mode 100644 index 0000000..7c6355c --- /dev/null +++ b/.config/nvim/after/plugin/telescope.rc.lua @@ -0,0 +1,63 @@ +local status, telescope = pcall(require, "telescope") + +if not status then return end + +local actions = require("telescope.actions") +local builtin = require("telescope.builtin") + +local fb_actions = require "telescope".extensions.file_browser.actions + +local function telescope_buffer_dir() + return vim.fn.expand("%:p:h") +end + +telescope.setup({ + defaults = { + mappings = { + n = { + ['q'] = actions.close + } + } + }, + extensions = { + file_browser = { + theme = "dropdown", + hijack_netrw = true, + hidden = true, + mappings = { + ['i'] = { + [''] = function() vim.cmd("normal vbd") end + }, + ['n'] = { + ['N'] = fb_actions.create, + ['h'] = fb_actions.goto_parent_dir, + ['/'] = function() vim.cmd("startinsert") end, + ['D'] = fb_actions.remove + } + } + } + } +}) + +telescope.load_extension("file_browser") + + +-- Set up keymaps specific to telescope +vim.keymap.set("n", ";f", function() + builtin.find_files({ no_ignore = false, hidden = true }) +end) +vim.keymap.set("n", ";g", builtin.git_files) +vim.keymap.set("n", "sf", + function() + telescope.extensions.file_browser.file_browser({ + path = "%:p:h", + cwd = telescope_buffer_dir(), + respect_gitignore = true, + hidden = true, + grouped = true, + previewer = false, + initial_mode = "normal", + layout_config = { height = 40 } + }) + end) +vim.keymap.set("n", ";h", builtin.help_tags) diff --git a/.config/nvim/after/plugin/treesitter.rc.lua b/.config/nvim/after/plugin/treesitter.rc.lua new file mode 100644 index 0000000..c9ca698 --- /dev/null +++ b/.config/nvim/after/plugin/treesitter.rc.lua @@ -0,0 +1,19 @@ +local status, treesitter = pcall(require, "nvim-treesitter.configs") + +if not status then return end + +treesitter.setup { + -- A list of parser names, or "all" + ensure_installed = { "vimdoc", "javascript", "typescript", "c", "lua", "rust" }, + + -- Install parsers synchronously (only applied to `ensure_installed`) + sync_install = false, + + -- Automatically install missing parsers when entering buffer + -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally + auto_install = true, + + highlight = { + enable = true, + }, +} diff --git a/.config/nvim/after/plugin/undotree.rc.lua b/.config/nvim/after/plugin/undotree.rc.lua new file mode 100644 index 0000000..a753ae8 --- /dev/null +++ b/.config/nvim/after/plugin/undotree.rc.lua @@ -0,0 +1,16 @@ +vim.keymap.set("n", "u", vim.cmd.UndotreeToggle) + +local has_persistent_undo = vim.api.nvim_call_function("has", { "persistent_undo" }) + +if has_persistent_undo then + local target_path = vim.api.nvim_call_function("expand", { "~/.undodir" }) + + local is_directory = vim.api.nvim_call_function("isdirectory", { target_path }) + + if not is_directory then + vim.api.nvim_call_function("mkdir", { target_path, "p", 0700 }) + end + + vim.opt.undodir = target_path + vim.opt.undofile = true +end diff --git a/.config/nvim/lua/juancwu/keymaps.lua b/.config/nvim/lua/juancwu/keymaps.lua index a3cadb8..42b3e48 100644 --- a/.config/nvim/lua/juancwu/keymaps.lua +++ b/.config/nvim/lua/juancwu/keymaps.lua @@ -1,7 +1,12 @@ vim.g.mapleader = " " +-- easy escape +vim.keymap.set("i", "", "", { noremap = true, silent = true }) +vim.keymap.set("v", "", "", { noremap = true, silent = true }) +vim.keymap.set("n", "", "", { noremap = true, silent = true }) + -- open the explorer -vim.keymap.set("n", "e", "Ex") +vim.keymap.set("n", "e", "Ex") -- move highlighted lines vim.keymap.set("v", "J", ":m '>+1gv=gv") @@ -21,8 +26,10 @@ vim.keymap.set("n", "N", "Nzzzv") -- do not copy with x, for god sake, WHY copy something that is being deleted?? vim.keymap.set("n", "x", "\"_x") --- smile +-- smile :) vim.keymap.set("n", "Q", "") +vim.keymap.set("n", "q", "", { noremap = true }) +vim.keymap.set("n", "q", "q", { noremap = true }) -- select and replace vim.keymap.set("n", "s", [[:%s/\<\>//gI]]) @@ -32,8 +39,8 @@ vim.keymap.set("n", "dd", "\"_dd") vim.keymap.set("n", "dd", "dd") -- cut line, under my control -- copy/paste to/from system clipboard -vim.keymap.set({"n", "v"}, "y", "\"+y") -vim.keymap.set({"n", "v"}, "p", "\"+p") +vim.keymap.set({ "n", "v" }, "y", "\"+y") +vim.keymap.set({ "n", "v" }, "p", "\"+p") -- increment/decrement a count, helpful for changing indeces vim.keymap.set("n", "+", "") @@ -51,7 +58,7 @@ vim.keymap.set("n", "db", "vbd") vim.keymap.set("n", "", "ggG") -- select all -- split pane -vim.keymap.set("n", "ss", ":splitw", { silent = true }) -- horizontal +vim.keymap.set("n", "ss", ":splitw", { silent = true }) -- horizontal vim.keymap.set("n", "sv", ":vsplitw", { silent = true }) -- vertical -- pane movement @@ -66,3 +73,17 @@ vim.keymap.set("n", "", "<") vim.keymap.set("n", "", ">") vim.keymap.set("n", "", "+") vim.keymap.set("n", "", "-") + +-- my arrow keys babyyyy +vim.keymap.set("i", "", "", { noremap = true }) +vim.keymap.set("i", "", "", { noremap = true }) +vim.keymap.set("i", "", "", { noremap = true }) +vim.keymap.set("i", "", "", { noremap = true }) + +-- terminal keymaps +vim.keymap.set("t", "", "", { noremap = true }) +vim.keymap.set("t", "", "bd!", { noremap = true }) +vim.keymap.set("n", "", "termi", { noremap = true }) + +-- lazygit on floaterm +vim.keymap.set("n", "g", "FloatermNew lazygit", { noremap = true }) diff --git a/.config/nvim/lua/juancwu/packer.lua b/.config/nvim/lua/juancwu/packer.lua index 3fbc948..051c282 100644 --- a/.config/nvim/lua/juancwu/packer.lua +++ b/.config/nvim/lua/juancwu/packer.lua @@ -2,31 +2,67 @@ vim.cmd [[packadd packer.nvim]] return require('packer').startup(function(use) - -- Packer can manage itself - use 'wbthomason/packer.nvim' + -- Packer can manage itself + use 'wbthomason/packer.nvim' - -- Themes - use({ 'rose-pine/neovim', as = 'rose-pine' }) + -- Themes + use({ 'rose-pine/neovim', as = 'rose-pine' }) - -- Sweet LSP - use { - 'VonHeikemen/lsp-zero.nvim', - branch = 'v2.x', - requires = { - -- LSP Support - {'neovim/nvim-lspconfig'}, -- Required - { -- Optional - 'williamboman/mason.nvim', - run = function() - pcall(vim.cmd, 'MasonUpdate') - end, - }, - {'williamboman/mason-lspconfig.nvim'}, -- Optional + -- Sweet LSP + use { + 'VonHeikemen/lsp-zero.nvim', + branch = 'v2.x', + requires = { + -- LSP Support + { 'neovim/nvim-lspconfig' }, -- Required + { -- Optional + 'williamboman/mason.nvim', + run = function() + pcall(vim.cmd, 'MasonUpdate') + end, + }, + { 'williamboman/mason-lspconfig.nvim' }, -- Optional - -- Autocompletion - {'hrsh7th/nvim-cmp'}, -- Required - {'hrsh7th/cmp-nvim-lsp'}, -- Required - {'L3MON4D3/LuaSnip'}, -- Required + -- Autocompletion + { 'hrsh7th/nvim-cmp' }, -- Required + { 'hrsh7th/cmp-nvim-lsp' }, -- Required + { 'L3MON4D3/LuaSnip' }, -- Required + } } - } + + -- Telescope for the fine file navigation + use { + 'nvim-telescope/telescope.nvim', tag = '0.1.2', + requires = { { 'nvim-lua/plenary.nvim' } } + } + + use { + "nvim-telescope/telescope-file-browser.nvim", + requires = { "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim" } + } + + use('nvim-treesitter/nvim-treesitter', { run = ':TSUpdate' }) + + use { + 'nvim-lualine/lualine.nvim', + requires = { 'nvim-tree/nvim-web-devicons', opt = true } + } + + -- autopairs, complete brackets + use { + "windwp/nvim-autopairs", + config = function() require("nvim-autopairs").setup {} end + } + + -- auto closing tags + use "windwp/nvim-ts-autotag" + + -- quick navigation between files, harpoon + use 'ThePrimeagen/harpoon' + + -- shows a history to undo + use 'mbbill/undotree' + + -- float window for terminal commands + use 'voldikss/vim-floaterm' end) From 88a8d00fd35f55c41f00e93dc8ee9142a9238fde Mon Sep 17 00:00:00 2001 From: juancwu <46619361+juancwu@users.noreply.github.com> Date: Fri, 7 Jul 2023 01:12:36 -0400 Subject: [PATCH 14/19] put back DISPLAY env for copy pasta --- .config/fish/config-linux.fish | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.config/fish/config-linux.fish b/.config/fish/config-linux.fish index c9a5556..b6e7a02 100644 --- a/.config/fish/config-linux.fish +++ b/.config/fish/config-linux.fish @@ -1,6 +1,6 @@ #x-server -#set -g DISPLAY $(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0 -# -#if test -x (command -v npiperelay.exe) -# source (dirname (status --current-file))/config-npiperelay.fish -#end +set -g DISPLAY $(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0 + +if test -x (command -v npiperelay.exe) + source (dirname (status --current-file))/config-npiperelay.fish +end From 0a1d0dcaab630946bfaedba08eed2c1851c2f06e Mon Sep 17 00:00:00 2001 From: juancwu <46619361+juancwu@users.noreply.github.com> Date: Sat, 8 Jul 2023 16:28:39 -0400 Subject: [PATCH 15/19] default node version 18 --- .config/nvm/nvmrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/nvm/nvmrc b/.config/nvm/nvmrc index b6a7d89..0e9dc6b 100644 --- a/.config/nvm/nvmrc +++ b/.config/nvm/nvmrc @@ -1 +1 @@ -16 +v18.13.0 From 346da1868d90760c2a9963ab0a47c7ace0f10d07 Mon Sep 17 00:00:00 2001 From: juancwu <46619361+juancwu@users.noreply.github.com> Date: Sat, 8 Jul 2023 16:29:53 -0400 Subject: [PATCH 16/19] start neovim config from new --- .config/nvim/after/plugin/autopairs.rc.lua | 7 -- .config/nvim/after/plugin/autotags.rc.lua | 5 -- .config/nvim/after/plugin/harpoon.rc.lua | 18 ----- .config/nvim/after/plugin/lspzero.rc.lua | 45 ----------- .config/nvim/after/plugin/lualine.rc.lua | 52 ------------ .config/nvim/after/plugin/telescope.rc.lua | 63 --------------- .config/nvim/after/plugin/treesitter.rc.lua | 19 ----- .config/nvim/after/plugin/undotree.rc.lua | 16 ---- .config/nvim/init.lua | 1 - .config/nvim/lua/juancwu/clipboard.lua | 12 --- .config/nvim/lua/juancwu/init.lua | 4 - .config/nvim/lua/juancwu/keymaps.lua | 89 --------------------- .config/nvim/lua/juancwu/options.lua | 41 ---------- .config/nvim/lua/juancwu/packer.lua | 68 ---------------- .config/nvim/lua/juancwu/theme.lua | 1 - 15 files changed, 441 deletions(-) delete mode 100644 .config/nvim/after/plugin/autopairs.rc.lua delete mode 100644 .config/nvim/after/plugin/autotags.rc.lua delete mode 100644 .config/nvim/after/plugin/harpoon.rc.lua delete mode 100644 .config/nvim/after/plugin/lspzero.rc.lua delete mode 100644 .config/nvim/after/plugin/lualine.rc.lua delete mode 100644 .config/nvim/after/plugin/telescope.rc.lua delete mode 100644 .config/nvim/after/plugin/treesitter.rc.lua delete mode 100644 .config/nvim/after/plugin/undotree.rc.lua delete mode 100644 .config/nvim/init.lua delete mode 100644 .config/nvim/lua/juancwu/clipboard.lua delete mode 100644 .config/nvim/lua/juancwu/init.lua delete mode 100644 .config/nvim/lua/juancwu/keymaps.lua delete mode 100644 .config/nvim/lua/juancwu/options.lua delete mode 100644 .config/nvim/lua/juancwu/packer.lua delete mode 100644 .config/nvim/lua/juancwu/theme.lua diff --git a/.config/nvim/after/plugin/autopairs.rc.lua b/.config/nvim/after/plugin/autopairs.rc.lua deleted file mode 100644 index 995f63b..0000000 --- a/.config/nvim/after/plugin/autopairs.rc.lua +++ /dev/null @@ -1,7 +0,0 @@ -local status, autopairs = pcall(require, "nvim-autopairs") - -if not status then return end - -autopairs.setup({ - disable_filetype = { "TelescopePrompt", "vim" } -}) diff --git a/.config/nvim/after/plugin/autotags.rc.lua b/.config/nvim/after/plugin/autotags.rc.lua deleted file mode 100644 index 4b339e4..0000000 --- a/.config/nvim/after/plugin/autotags.rc.lua +++ /dev/null @@ -1,5 +0,0 @@ -local status, autotag = pcall(require, "nvim-ts-autotag") - -if not status then return end - -autotag.setup() diff --git a/.config/nvim/after/plugin/harpoon.rc.lua b/.config/nvim/after/plugin/harpoon.rc.lua deleted file mode 100644 index 5ff77d5..0000000 --- a/.config/nvim/after/plugin/harpoon.rc.lua +++ /dev/null @@ -1,18 +0,0 @@ -local status, mark = pcall(require, "harpoon.mark") - -if not status then return end - -local ui -status, ui = pcall(require, "harpoon.ui") - -if not status then return end - -vim.keymap.set("n", "a", mark.add_file) -vim.keymap.set("n", "", ui.toggle_quick_menu) - -vim.keymap.set("n", "q", function() ui.nav_file(1) end) -vim.keymap.set("n", "w", function() ui.nav_file(2) end) -vim.keymap.set("n", "e", function() ui.nav_file(3) end) -vim.keymap.set("n", "r", function() ui.nav_file(4) end) -vim.keymap.set("n", ",", ui.nav_prev) -vim.keymap.set("n", ".", ui.nav_next) diff --git a/.config/nvim/after/plugin/lspzero.rc.lua b/.config/nvim/after/plugin/lspzero.rc.lua deleted file mode 100644 index b95a5b4..0000000 --- a/.config/nvim/after/plugin/lspzero.rc.lua +++ /dev/null @@ -1,45 +0,0 @@ -local status, lspzero = pcall(require, "lsp-zero") - -if not status then return end - -lspzero.preset("recommended") - --- first argument is the client -lspzero.on_attach(function(_, bufnr) - lspzero.default_keymaps({ buffer = bufnr }) - - -- custom keymaps - vim.keymap.set("n", "f", "lua vim.lsp.buf.format()") -- format buffer -end) - --- Enable format on save -lspzero.format_on_save({ - format_opts = { - async = true, - timeout_ms = 10000, - }, - servers = { - ['lua_ls'] = { 'lua' }, - } -}) - -local lspconfig -status, lspconfig = pcall(require, "lspconfig") - -if status then - lspconfig.lua_ls.setup(lspzero.nvim_lua_ls()) -end - -lspzero.setup() - -local cmp -status, cmp = pcall(require, 'cmp') - -if not status then return end - -cmp.setup({ - mapping = { - -- Press "Enter" to confirm completion/suggestion - [''] = cmp.mapping.confirm({ select = true }), - } -}) diff --git a/.config/nvim/after/plugin/lualine.rc.lua b/.config/nvim/after/plugin/lualine.rc.lua deleted file mode 100644 index a582996..0000000 --- a/.config/nvim/after/plugin/lualine.rc.lua +++ /dev/null @@ -1,52 +0,0 @@ -local status, lualine = pcall(require, 'lualine') - -if (not status) then return end - -lualine.setup { - options = { - icons_enabled = true, - section_separators = { - left = '', - right = '' - }, - component_separators = { - left = '', - right = '' - }, - disabled_filetypes = {} - }, - sections = { - lualine_a = { 'mode' }, - lualine_b = { 'branch' }, - lualine_c = { { - 'filename', - file_status = true, -- display file status - path = 0 -- no file path - } }, - lualine_x = { - { - 'diagnostics', - sources = { 'nvim_diagnostic' }, - symbols = { error = ' ', warn = ' ', info = ' ', hint = '' } - }, - 'enconding', - 'filetype' - }, - lualine_y = { 'progress' }, - lualine_z = { 'location' } - }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = { { - 'filename', - file_status = true, - path = 1 - } }, - lualine_x = { 'location' }, - lualine_y = {}, - lualine_z = {} - }, - tabline = {}, - extensions = { 'fugitive' } -} diff --git a/.config/nvim/after/plugin/telescope.rc.lua b/.config/nvim/after/plugin/telescope.rc.lua deleted file mode 100644 index 7c6355c..0000000 --- a/.config/nvim/after/plugin/telescope.rc.lua +++ /dev/null @@ -1,63 +0,0 @@ -local status, telescope = pcall(require, "telescope") - -if not status then return end - -local actions = require("telescope.actions") -local builtin = require("telescope.builtin") - -local fb_actions = require "telescope".extensions.file_browser.actions - -local function telescope_buffer_dir() - return vim.fn.expand("%:p:h") -end - -telescope.setup({ - defaults = { - mappings = { - n = { - ['q'] = actions.close - } - } - }, - extensions = { - file_browser = { - theme = "dropdown", - hijack_netrw = true, - hidden = true, - mappings = { - ['i'] = { - [''] = function() vim.cmd("normal vbd") end - }, - ['n'] = { - ['N'] = fb_actions.create, - ['h'] = fb_actions.goto_parent_dir, - ['/'] = function() vim.cmd("startinsert") end, - ['D'] = fb_actions.remove - } - } - } - } -}) - -telescope.load_extension("file_browser") - - --- Set up keymaps specific to telescope -vim.keymap.set("n", ";f", function() - builtin.find_files({ no_ignore = false, hidden = true }) -end) -vim.keymap.set("n", ";g", builtin.git_files) -vim.keymap.set("n", "sf", - function() - telescope.extensions.file_browser.file_browser({ - path = "%:p:h", - cwd = telescope_buffer_dir(), - respect_gitignore = true, - hidden = true, - grouped = true, - previewer = false, - initial_mode = "normal", - layout_config = { height = 40 } - }) - end) -vim.keymap.set("n", ";h", builtin.help_tags) diff --git a/.config/nvim/after/plugin/treesitter.rc.lua b/.config/nvim/after/plugin/treesitter.rc.lua deleted file mode 100644 index c9ca698..0000000 --- a/.config/nvim/after/plugin/treesitter.rc.lua +++ /dev/null @@ -1,19 +0,0 @@ -local status, treesitter = pcall(require, "nvim-treesitter.configs") - -if not status then return end - -treesitter.setup { - -- A list of parser names, or "all" - ensure_installed = { "vimdoc", "javascript", "typescript", "c", "lua", "rust" }, - - -- Install parsers synchronously (only applied to `ensure_installed`) - sync_install = false, - - -- Automatically install missing parsers when entering buffer - -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally - auto_install = true, - - highlight = { - enable = true, - }, -} diff --git a/.config/nvim/after/plugin/undotree.rc.lua b/.config/nvim/after/plugin/undotree.rc.lua deleted file mode 100644 index a753ae8..0000000 --- a/.config/nvim/after/plugin/undotree.rc.lua +++ /dev/null @@ -1,16 +0,0 @@ -vim.keymap.set("n", "u", vim.cmd.UndotreeToggle) - -local has_persistent_undo = vim.api.nvim_call_function("has", { "persistent_undo" }) - -if has_persistent_undo then - local target_path = vim.api.nvim_call_function("expand", { "~/.undodir" }) - - local is_directory = vim.api.nvim_call_function("isdirectory", { target_path }) - - if not is_directory then - vim.api.nvim_call_function("mkdir", { target_path, "p", 0700 }) - end - - vim.opt.undodir = target_path - vim.opt.undofile = true -end diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua deleted file mode 100644 index 099652f..0000000 --- a/.config/nvim/init.lua +++ /dev/null @@ -1 +0,0 @@ -require("juancwu") diff --git a/.config/nvim/lua/juancwu/clipboard.lua b/.config/nvim/lua/juancwu/clipboard.lua deleted file mode 100644 index 9c3eb14..0000000 --- a/.config/nvim/lua/juancwu/clipboard.lua +++ /dev/null @@ -1,12 +0,0 @@ -vim.g.clipboard = { - name = "win32yank", - copy = { - ['+'] = "win32yank.exe -i --crlf", - ['*'] = "win32yank.exe -i --crlf", - }, - paste = { - ['+'] = "win32yank.exe -o --lf", - ['*'] = "win32yank.exe -o --lf", - }, - cache_enabled = 0, -} diff --git a/.config/nvim/lua/juancwu/init.lua b/.config/nvim/lua/juancwu/init.lua deleted file mode 100644 index 84f29a6..0000000 --- a/.config/nvim/lua/juancwu/init.lua +++ /dev/null @@ -1,4 +0,0 @@ -require("juancwu.keymaps") -require("juancwu.options") -require("juancwu.theme") -require("juancwu.clipboard") diff --git a/.config/nvim/lua/juancwu/keymaps.lua b/.config/nvim/lua/juancwu/keymaps.lua deleted file mode 100644 index 42b3e48..0000000 --- a/.config/nvim/lua/juancwu/keymaps.lua +++ /dev/null @@ -1,89 +0,0 @@ -vim.g.mapleader = " " - --- easy escape -vim.keymap.set("i", "", "", { noremap = true, silent = true }) -vim.keymap.set("v", "", "", { noremap = true, silent = true }) -vim.keymap.set("n", "", "", { noremap = true, silent = true }) - --- open the explorer -vim.keymap.set("n", "e", "Ex") - --- move highlighted lines -vim.keymap.set("v", "J", ":m '>+1gv=gv") -vim.keymap.set("v", "K", ":m '<-2gv=gv") - --- make cursor stay in same position when appending line below -vim.keymap.set("n", "J", "mzJ`z") - --- make cursor stay in the middle while moving down/up the page -vim.keymap.set("n", "", "zz") -vim.keymap.set("n", "", "zz") - --- make cursor stay in the middle while looking through search results -vim.keymap.set("n", "n", "nzzzv") -vim.keymap.set("n", "N", "Nzzzv") - --- do not copy with x, for god sake, WHY copy something that is being deleted?? -vim.keymap.set("n", "x", "\"_x") - --- smile :) -vim.keymap.set("n", "Q", "") -vim.keymap.set("n", "q", "", { noremap = true }) -vim.keymap.set("n", "q", "q", { noremap = true }) - --- select and replace -vim.keymap.set("n", "s", [[:%s/\<\>//gI]]) - --- no copy, delete line, for god sake... -vim.keymap.set("n", "dd", "\"_dd") -vim.keymap.set("n", "dd", "dd") -- cut line, under my control - --- copy/paste to/from system clipboard -vim.keymap.set({ "n", "v" }, "y", "\"+y") -vim.keymap.set({ "n", "v" }, "p", "\"+p") - --- increment/decrement a count, helpful for changing indeces -vim.keymap.set("n", "+", "") -vim.keymap.set("n", "-", "") - --- do not copy when deleting word -vim.keymap.set("n", "dw", "\"_dw") -vim.keymap.set("n", "de", "\"_de") -vim.keymap.set("n", "dw", "dw") -vim.keymap.set("n", "de", "de") - -vim.keymap.set("n", "db", "vb\"_d") -- delete in backwards -vim.keymap.set("n", "db", "vbd") - -vim.keymap.set("n", "", "ggG") -- select all - --- split pane -vim.keymap.set("n", "ss", ":splitw", { silent = true }) -- horizontal -vim.keymap.set("n", "sv", ":vsplitw", { silent = true }) -- vertical - --- pane movement -vim.keymap.set("n", "..", "w") -- toggle -vim.keymap.set("n", "sh", "h") -vim.keymap.set("n", "sk", "k") -vim.keymap.set("n", "sl", "l") -vim.keymap.set("n", "sj", "j") - --- resize pane -vim.keymap.set("n", "", "<") -vim.keymap.set("n", "", ">") -vim.keymap.set("n", "", "+") -vim.keymap.set("n", "", "-") - --- my arrow keys babyyyy -vim.keymap.set("i", "", "", { noremap = true }) -vim.keymap.set("i", "", "", { noremap = true }) -vim.keymap.set("i", "", "", { noremap = true }) -vim.keymap.set("i", "", "", { noremap = true }) - --- terminal keymaps -vim.keymap.set("t", "", "", { noremap = true }) -vim.keymap.set("t", "", "bd!", { noremap = true }) -vim.keymap.set("n", "", "termi", { noremap = true }) - --- lazygit on floaterm -vim.keymap.set("n", "g", "FloatermNew lazygit", { noremap = true }) diff --git a/.config/nvim/lua/juancwu/options.lua b/.config/nvim/lua/juancwu/options.lua deleted file mode 100644 index 87f4dc7..0000000 --- a/.config/nvim/lua/juancwu/options.lua +++ /dev/null @@ -1,41 +0,0 @@ -vim.scriptencoding = "utf-8" -vim.opt.encoding = "utf-8" -vim.opt.fileencoding = "utf-8" - -vim.wo.number = true -- show line number -vim.opt.relativenumber = true -- juicy relativity - -vim.opt.autoindent = true -vim.opt.smartindent = true -vim.opt.tabstop = 4 -vim.opt.softtabstop = 4 -vim.opt.shiftwidth = 4 -vim.opt.expandtab = true -vim.opt.smarttab = true -vim.opt.breakindent = true - -vim.opt.wrap = false -- bad, stay away from me! - -vim.opt.hlsearch = false -vim.opt.incsearch = true -- highlight search pattern as you type - -vim.opt.scrolloff = 8 -- give me some personal space - -vim.opt.updatetime = 50 - -vim.opt.ignorecase = true -- case-insensitive search - -vim.opt.backspace = { "start", "eol", "indent" } - --- don't want to look into these... -vim.opt.wildignore:append { "*/node_modules/*", "*/__pycache__/*" } - --- add '*' in block comments -vim.opt.formatoptions:append { 'r' } - --- theme -vim.opt.winblend = 0 -vim.opt.wildoptions = "pum" -- show popup for autocomplete -vim.opt.pumblend = 5 -vim.opt.background = "dark" -vim.opt.termguicolors = true -- good shit, just take it diff --git a/.config/nvim/lua/juancwu/packer.lua b/.config/nvim/lua/juancwu/packer.lua deleted file mode 100644 index 051c282..0000000 --- a/.config/nvim/lua/juancwu/packer.lua +++ /dev/null @@ -1,68 +0,0 @@ --- Only required if you have packer configured as `opt` -vim.cmd [[packadd packer.nvim]] - -return require('packer').startup(function(use) - -- Packer can manage itself - use 'wbthomason/packer.nvim' - - -- Themes - use({ 'rose-pine/neovim', as = 'rose-pine' }) - - -- Sweet LSP - use { - 'VonHeikemen/lsp-zero.nvim', - branch = 'v2.x', - requires = { - -- LSP Support - { 'neovim/nvim-lspconfig' }, -- Required - { -- Optional - 'williamboman/mason.nvim', - run = function() - pcall(vim.cmd, 'MasonUpdate') - end, - }, - { 'williamboman/mason-lspconfig.nvim' }, -- Optional - - -- Autocompletion - { 'hrsh7th/nvim-cmp' }, -- Required - { 'hrsh7th/cmp-nvim-lsp' }, -- Required - { 'L3MON4D3/LuaSnip' }, -- Required - } - } - - -- Telescope for the fine file navigation - use { - 'nvim-telescope/telescope.nvim', tag = '0.1.2', - requires = { { 'nvim-lua/plenary.nvim' } } - } - - use { - "nvim-telescope/telescope-file-browser.nvim", - requires = { "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim" } - } - - use('nvim-treesitter/nvim-treesitter', { run = ':TSUpdate' }) - - use { - 'nvim-lualine/lualine.nvim', - requires = { 'nvim-tree/nvim-web-devicons', opt = true } - } - - -- autopairs, complete brackets - use { - "windwp/nvim-autopairs", - config = function() require("nvim-autopairs").setup {} end - } - - -- auto closing tags - use "windwp/nvim-ts-autotag" - - -- quick navigation between files, harpoon - use 'ThePrimeagen/harpoon' - - -- shows a history to undo - use 'mbbill/undotree' - - -- float window for terminal commands - use 'voldikss/vim-floaterm' -end) diff --git a/.config/nvim/lua/juancwu/theme.lua b/.config/nvim/lua/juancwu/theme.lua deleted file mode 100644 index 3240184..0000000 --- a/.config/nvim/lua/juancwu/theme.lua +++ /dev/null @@ -1 +0,0 @@ -vim.cmd('colorscheme rose-pine') From 3d4bbb5710a73eece30afb826358c7861ddaf1de Mon Sep 17 00:00:00 2001 From: juancwu <46619361+juancwu@users.noreply.github.com> Date: Sun, 9 Jul 2023 01:27:48 -0400 Subject: [PATCH 17/19] new nvim config with lazy.nvim --- .config/nvim/.gitignore | 1 - .config/nvim/init.lua | 19 ++++ .config/nvim/lazy-lock.json | 27 ++++++ .config/nvim/lua/clipboard.lua | 12 +++ .config/nvim/lua/keymaps.lua | 89 +++++++++++++++++++ .config/nvim/lua/options.lua | 44 +++++++++ .config/nvim/lua/plugins/autopairs.lua | 7 ++ .config/nvim/lua/plugins/autotag.lua | 8 ++ .config/nvim/lua/plugins/comment.lua | 34 +++++++ .config/nvim/lua/plugins/floaterm.lua | 6 ++ .config/nvim/lua/plugins/gitsigns.lua | 12 +++ .config/nvim/lua/plugins/harpoon.lua | 18 ++++ .config/nvim/lua/plugins/lsp-zero.lua | 76 ++++++++++++++++ .config/nvim/lua/plugins/lualine.lua | 56 ++++++++++++ .config/nvim/lua/plugins/null-ls.lua | 15 ++++ .config/nvim/lua/plugins/rose-pine.lua | 7 ++ .../lua/plugins/telescope-file-browser.lua | 7 ++ .config/nvim/lua/plugins/telescope.lua | 70 +++++++++++++++ .config/nvim/lua/plugins/todo-comments.lua | 5 ++ .config/nvim/lua/plugins/treesitter.lua | 27 ++++++ .config/nvim/lua/plugins/undotree.lua | 22 +++++ 21 files changed, 561 insertions(+), 1 deletion(-) create mode 100644 .config/nvim/init.lua create mode 100644 .config/nvim/lazy-lock.json create mode 100644 .config/nvim/lua/clipboard.lua create mode 100644 .config/nvim/lua/keymaps.lua create mode 100644 .config/nvim/lua/options.lua create mode 100644 .config/nvim/lua/plugins/autopairs.lua create mode 100644 .config/nvim/lua/plugins/autotag.lua create mode 100644 .config/nvim/lua/plugins/comment.lua create mode 100644 .config/nvim/lua/plugins/floaterm.lua create mode 100644 .config/nvim/lua/plugins/gitsigns.lua create mode 100644 .config/nvim/lua/plugins/harpoon.lua create mode 100644 .config/nvim/lua/plugins/lsp-zero.lua create mode 100644 .config/nvim/lua/plugins/lualine.lua create mode 100644 .config/nvim/lua/plugins/null-ls.lua create mode 100644 .config/nvim/lua/plugins/rose-pine.lua create mode 100644 .config/nvim/lua/plugins/telescope-file-browser.lua create mode 100644 .config/nvim/lua/plugins/telescope.lua create mode 100644 .config/nvim/lua/plugins/todo-comments.lua create mode 100644 .config/nvim/lua/plugins/treesitter.lua create mode 100644 .config/nvim/lua/plugins/undotree.lua diff --git a/.config/nvim/.gitignore b/.config/nvim/.gitignore index d547881..e69de29 100644 --- a/.config/nvim/.gitignore +++ b/.config/nvim/.gitignore @@ -1 +0,0 @@ -packer_compiled.lua diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua new file mode 100644 index 0000000..07dad03 --- /dev/null +++ b/.config/nvim/init.lua @@ -0,0 +1,19 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) + +-- custom modules: +require("keymaps") +require("clipboard") +require("options") + +require("lazy").setup("plugins") diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json new file mode 100644 index 0000000..9df48e8 --- /dev/null +++ b/.config/nvim/lazy-lock.json @@ -0,0 +1,27 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "176e85eeb63f1a5970d6b88f1725039d85ca0055" }, + "LuaSnip": { "branch": "master", "commit": "a658ae2906344a1d2b9c507738e585cf68e685c7" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, + "gitsigns.nvim": { "branch": "main", "commit": "dc2962f7fce953a2a98e7c6d3d7fc4c1d1f66758" }, + "harpoon": { "branch": "master", "commit": "21f4c47c6803d64ddb934a5b314dcb1b8e7365dc" }, + "lazy.nvim": { "branch": "main", "commit": "5af331ea65418dc9361769891921fdee4bcc837a" }, + "lsp-zero.nvim": { "branch": "v2.x", "commit": "7b9627c2cb50906993e194290b2e539c95dfdf47" }, + "lualine.nvim": { "branch": "master", "commit": "05d78e9fd0cdfb4545974a5aa14b1be95a86e9c9" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "82685fdd0f67a694b244cb058b83761f54664d68" }, + "mason.nvim": { "branch": "main", "commit": "5ad3e113b0c3fde3caba8630599373046f6197e8" }, + "null-ls.nvim": { "branch": "main", "commit": "db09b6c691def0038c456551e4e2772186449f35" }, + "nvim-autopairs": { "branch": "master", "commit": "e8f7dd7a72de3e7b6626c050a802000e69d53ff0" }, + "nvim-cmp": { "branch": "main", "commit": "2743dd989e9b932e1b4813a4927d7b84272a14e2" }, + "nvim-lspconfig": { "branch": "master", "commit": "deade69789089c3da15237697156334fb3e943f0" }, + "nvim-treesitter": { "branch": "master", "commit": "d9104a1d10023ed9e7eacf68639ad887425246eb" }, + "nvim-ts-autotag": { "branch": "main", "commit": "6be1192965df35f94b8ea6d323354f7dc7a557e4" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "7f625207f225eea97ef7a6abe7611e556c396d2f" }, + "nvim-web-devicons": { "branch": "master", "commit": "9ab9b0b894b2388a9dbcdee5f00ce72e25d85bf9" }, + "plenary.nvim": { "branch": "master", "commit": "bda256fab0eb66a15e8190937e417e6a14ee5d72" }, + "rose-pine": { "branch": "main", "commit": "932adb0d9351186db047302de021bb2976756a07" }, + "telescope-file-browser.nvim": { "branch": "master", "commit": "e03ff55962417b69c85ef41424079bb0580546ba" }, + "telescope.nvim": { "branch": "master", "commit": "776b509f80dd49d8205b9b0d94485568236d1192" }, + "todo-comments.nvim": { "branch": "main", "commit": "09b0b17d824d2d56f02ff15967e8a2499a89c731" }, + "undotree": { "branch": "master", "commit": "0e11ba7325efbbb3f3bebe06213afa3e7ec75131" }, + "vim-floaterm": { "branch": "master", "commit": "bd0aee3c861d613f56b85bd9eaffdcab459071fd" } +} \ No newline at end of file diff --git a/.config/nvim/lua/clipboard.lua b/.config/nvim/lua/clipboard.lua new file mode 100644 index 0000000..9c3eb14 --- /dev/null +++ b/.config/nvim/lua/clipboard.lua @@ -0,0 +1,12 @@ +vim.g.clipboard = { + name = "win32yank", + copy = { + ['+'] = "win32yank.exe -i --crlf", + ['*'] = "win32yank.exe -i --crlf", + }, + paste = { + ['+'] = "win32yank.exe -o --lf", + ['*'] = "win32yank.exe -o --lf", + }, + cache_enabled = 0, +} diff --git a/.config/nvim/lua/keymaps.lua b/.config/nvim/lua/keymaps.lua new file mode 100644 index 0000000..42b3e48 --- /dev/null +++ b/.config/nvim/lua/keymaps.lua @@ -0,0 +1,89 @@ +vim.g.mapleader = " " + +-- easy escape +vim.keymap.set("i", "", "", { noremap = true, silent = true }) +vim.keymap.set("v", "", "", { noremap = true, silent = true }) +vim.keymap.set("n", "", "", { noremap = true, silent = true }) + +-- open the explorer +vim.keymap.set("n", "e", "Ex") + +-- move highlighted lines +vim.keymap.set("v", "J", ":m '>+1gv=gv") +vim.keymap.set("v", "K", ":m '<-2gv=gv") + +-- make cursor stay in same position when appending line below +vim.keymap.set("n", "J", "mzJ`z") + +-- make cursor stay in the middle while moving down/up the page +vim.keymap.set("n", "", "zz") +vim.keymap.set("n", "", "zz") + +-- make cursor stay in the middle while looking through search results +vim.keymap.set("n", "n", "nzzzv") +vim.keymap.set("n", "N", "Nzzzv") + +-- do not copy with x, for god sake, WHY copy something that is being deleted?? +vim.keymap.set("n", "x", "\"_x") + +-- smile :) +vim.keymap.set("n", "Q", "") +vim.keymap.set("n", "q", "", { noremap = true }) +vim.keymap.set("n", "q", "q", { noremap = true }) + +-- select and replace +vim.keymap.set("n", "s", [[:%s/\<\>//gI]]) + +-- no copy, delete line, for god sake... +vim.keymap.set("n", "dd", "\"_dd") +vim.keymap.set("n", "dd", "dd") -- cut line, under my control + +-- copy/paste to/from system clipboard +vim.keymap.set({ "n", "v" }, "y", "\"+y") +vim.keymap.set({ "n", "v" }, "p", "\"+p") + +-- increment/decrement a count, helpful for changing indeces +vim.keymap.set("n", "+", "") +vim.keymap.set("n", "-", "") + +-- do not copy when deleting word +vim.keymap.set("n", "dw", "\"_dw") +vim.keymap.set("n", "de", "\"_de") +vim.keymap.set("n", "dw", "dw") +vim.keymap.set("n", "de", "de") + +vim.keymap.set("n", "db", "vb\"_d") -- delete in backwards +vim.keymap.set("n", "db", "vbd") + +vim.keymap.set("n", "", "ggG") -- select all + +-- split pane +vim.keymap.set("n", "ss", ":splitw", { silent = true }) -- horizontal +vim.keymap.set("n", "sv", ":vsplitw", { silent = true }) -- vertical + +-- pane movement +vim.keymap.set("n", "..", "w") -- toggle +vim.keymap.set("n", "sh", "h") +vim.keymap.set("n", "sk", "k") +vim.keymap.set("n", "sl", "l") +vim.keymap.set("n", "sj", "j") + +-- resize pane +vim.keymap.set("n", "", "<") +vim.keymap.set("n", "", ">") +vim.keymap.set("n", "", "+") +vim.keymap.set("n", "", "-") + +-- my arrow keys babyyyy +vim.keymap.set("i", "", "", { noremap = true }) +vim.keymap.set("i", "", "", { noremap = true }) +vim.keymap.set("i", "", "", { noremap = true }) +vim.keymap.set("i", "", "", { noremap = true }) + +-- terminal keymaps +vim.keymap.set("t", "", "", { noremap = true }) +vim.keymap.set("t", "", "bd!", { noremap = true }) +vim.keymap.set("n", "", "termi", { noremap = true }) + +-- lazygit on floaterm +vim.keymap.set("n", "g", "FloatermNew lazygit", { noremap = true }) diff --git a/.config/nvim/lua/options.lua b/.config/nvim/lua/options.lua new file mode 100644 index 0000000..1cb7748 --- /dev/null +++ b/.config/nvim/lua/options.lua @@ -0,0 +1,44 @@ +vim.scriptencoding = "utf-8" +vim.opt.encoding = "utf-8" +vim.opt.fileencoding = "utf-8" + +vim.wo.number = true -- show line number +vim.opt.relativenumber = true -- juicy relativity + +vim.opt.autoindent = true +vim.opt.smartindent = true +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true +vim.opt.smarttab = true +vim.opt.breakindent = true + +vim.opt.wrap = false -- bad, stay away from me! + +vim.opt.hlsearch = false +vim.opt.incsearch = true -- highlight search pattern as you type + +vim.opt.scrolloff = 8 -- give me some personal space + +vim.opt.updatetime = 50 + +vim.opt.ignorecase = true -- case-insensitive search + +vim.opt.backspace = { "start", "eol", "indent" } + +-- don't want to look into these... +vim.opt.wildignore:append { "*/node_modules/*", "*/__pycache__/*" } + +-- add '*' in block comments +vim.opt.formatoptions:append { 'r' } + +-- theme +vim.opt.winblend = 0 +vim.opt.wildoptions = "pum" -- show popup for autocomplete +vim.opt.pumblend = 5 +vim.opt.background = "dark" +vim.opt.termguicolors = true -- good shit, just take it + +-- activate persistent undo +vim.opt.undofile = true diff --git a/.config/nvim/lua/plugins/autopairs.lua b/.config/nvim/lua/plugins/autopairs.lua new file mode 100644 index 0000000..70f3d12 --- /dev/null +++ b/.config/nvim/lua/plugins/autopairs.lua @@ -0,0 +1,7 @@ +return { + "windwp/nvim-autopairs", + event = "InsertEnter", + config = { + disable_filetype = { "TelescopePrompt", "vim" } + }, +} diff --git a/.config/nvim/lua/plugins/autotag.lua b/.config/nvim/lua/plugins/autotag.lua new file mode 100644 index 0000000..5ac274b --- /dev/null +++ b/.config/nvim/lua/plugins/autotag.lua @@ -0,0 +1,8 @@ +return { + "windwp/nvim-ts-autotag", + dependencies = { "nvim-treesitter/nvim-treesitter", build = ':TSUpdate' }, + config = function() + local autotag = require('nvim-ts-autotag') + autotag.setup() + end +} diff --git a/.config/nvim/lua/plugins/comment.lua b/.config/nvim/lua/plugins/comment.lua new file mode 100644 index 0000000..89425bd --- /dev/null +++ b/.config/nvim/lua/plugins/comment.lua @@ -0,0 +1,34 @@ +return { + "numToStr/Comment.nvim", + dependencies = { + "JoosepAlviste/nvim-ts-context-commentstring", + }, + config = function() + local comment = require('Comment') + comment.setup({ + pre_hook = function(ctx) + -- only for tsx/jsx filetypes + if vim.bo.filetype == "typescriptreact" or vim.bo.filetype == "javascriptreact" then + local U = require('Comment.utils') + + -- determine wheter to use linwise or blockwise commentstring + local type = ctx.ctype == U.ctype.linewise and '__default' or '__multiline' + + + -- determine the location where to calcualte commentstring from + local location = nil + if ctx.ctype == U.ctype.blockwise then + location = require('ts_context_commentstring.utils').get_cursor_location() + elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then + location = require('ts_context_commentstring.utils').get_visual_start_location() + end + + return require('ts_context_commentstring.internal').calculate_commentstring({ + key = type, + location = location, + }) + end + end, + }) + end +} diff --git a/.config/nvim/lua/plugins/floaterm.lua b/.config/nvim/lua/plugins/floaterm.lua new file mode 100644 index 0000000..bd793d2 --- /dev/null +++ b/.config/nvim/lua/plugins/floaterm.lua @@ -0,0 +1,6 @@ +return { + "voldikss/vim-floaterm", + keys = { + { "gg", "FloatermNew lazygit", desc = "Open lazygit in a floating window" }, + }, +} diff --git a/.config/nvim/lua/plugins/gitsigns.lua b/.config/nvim/lua/plugins/gitsigns.lua new file mode 100644 index 0000000..5918f84 --- /dev/null +++ b/.config/nvim/lua/plugins/gitsigns.lua @@ -0,0 +1,12 @@ +return { + "lewis6991/gitsigns.nvim", + config = { + current_line_blame = true, + current_line_blame_opts = { + virt_text = true, + virt_text_pos = 'eol', + delay = 1000, + ignore_whitespace = false + }, + }, +} diff --git a/.config/nvim/lua/plugins/harpoon.lua b/.config/nvim/lua/plugins/harpoon.lua new file mode 100644 index 0000000..0169db7 --- /dev/null +++ b/.config/nvim/lua/plugins/harpoon.lua @@ -0,0 +1,18 @@ +return { + "ThePrimeagen/harpoon", + dependencies = { "nvim-lua/plenary.nvim" }, + config = function() + local mark = require("harpoon.mark") + local ui = require("harpoon.ui") + + vim.keymap.set("n", "a", mark.add_file) + vim.keymap.set("n", "", ui.toggle_quick_menu) + + vim.keymap.set("n", "q", function() ui.nav_file(1) end) + vim.keymap.set("n", "w", function() ui.nav_file(2) end) + vim.keymap.set("n", "e", function() ui.nav_file(3) end) + vim.keymap.set("n", "r", function() ui.nav_file(4) end) + vim.keymap.set("n", ",", ui.nav_prev) + vim.keymap.set("n", ".", ui.nav_next) + end +} diff --git a/.config/nvim/lua/plugins/lsp-zero.lua b/.config/nvim/lua/plugins/lsp-zero.lua new file mode 100644 index 0000000..0c8f69d --- /dev/null +++ b/.config/nvim/lua/plugins/lsp-zero.lua @@ -0,0 +1,76 @@ +return { + 'VonHeikemen/lsp-zero.nvim', + branch = 'v2.x', + dependencies = { + -- LSP Support + { 'neovim/nvim-lspconfig' }, -- Required + { -- Optional + 'williamboman/mason.nvim', + build = function() + pcall(vim.cmd, 'MasonUpdate') + end, + }, + { 'williamboman/mason-lspconfig.nvim' }, -- Optional + + -- Autocompletion + { 'hrsh7th/nvim-cmp' }, -- Required + { 'hrsh7th/cmp-nvim-lsp' }, -- Required + { 'L3MON4D3/LuaSnip' }, -- Required + }, + config = function() + local lspzero = require("lsp-zero") + + lspzero.preset("recommended") + + lspzero.on_attach(function(client, bufnr) + lspzero.default_keymaps({ buffer = bufnr }) + + -- format with space + f + vim.keymap.set("n", "f", "lua vim.lsp.buf.format()") + end) + + lspzero.ensure_installed({ + "tsserver", + "eslint", + "tailwindcss", + }) + + lspzero.format_on_save({ + format_ops = { + async = true, + timeout_ms = 10000, + }, + servers = { + ["lua_ls"] = { "lua" }, + ["null-ls"] = { + "javascript", + "typescript", + "javascriptreact", + "typescriptreact", + }, + }, + }) + + local status, lspconfig = pcall(require, "lspconfig") + + if status then + lspconfig.tsserver.setup({}) + lspconfig.tailwindcss.setup({}) + end + + lspzero.setup() + + local cmp + status, cmp = pcall(require, "cmp") + + if not status then return end + + cmp.setup({ + mapping = { + -- press 'enter' to confirm completion/suggestion + [''] = cmp.mapping.confirm({ select = true }), + [''] = cmp.mapping.abort(), + }, + }) + end +} diff --git a/.config/nvim/lua/plugins/lualine.lua b/.config/nvim/lua/plugins/lualine.lua new file mode 100644 index 0000000..5c0c025 --- /dev/null +++ b/.config/nvim/lua/plugins/lualine.lua @@ -0,0 +1,56 @@ +return { + "nvim-lualine/lualine.nvim", + dependencies = { "nvim-tree/nvim-web-devicons", lazy = true }, + config = function () + local lualine = require('lualine') + + lualine.setup { + options = { + icons_enabled = true, + section_separators = { + left = '', + right = '' + }, + component_separators = { + left = '', + right = '' + }, + disabled_filetypes = {} + }, + sections = { + lualine_a = { 'mode' }, + lualine_b = { 'branch' }, + lualine_c = { { + 'filename', + file_status = true, -- display file status + path = 0 -- no file path + } }, + lualine_x = { + { + 'diagnostics', + sources = { 'nvim_diagnostic' }, + symbols = { error = ' ', warn = ' ', info = ' ', hint = '' } + }, + 'enconding', + 'filetype' + }, + lualine_y = { 'progress' }, + lualine_z = { 'location' } + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { { + 'filename', + file_status = true, + path = 1 + } }, + lualine_x = { 'location' }, + lualine_y = {}, + lualine_z = {} + }, + tabline = {}, + extensions = { 'fugitive' } + } + end +} diff --git a/.config/nvim/lua/plugins/null-ls.lua b/.config/nvim/lua/plugins/null-ls.lua new file mode 100644 index 0000000..6b6b81a --- /dev/null +++ b/.config/nvim/lua/plugins/null-ls.lua @@ -0,0 +1,15 @@ +return { + "jose-elias-alvarez/null-ls.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + }, + config = function() + local null_ls = require("null-ls") + null_ls.setup({ + sources = { + null_ls.builtins.formatting.prettierd, + null_ls.builtins.diagnostics.eslint, + }, + }) + end +} diff --git a/.config/nvim/lua/plugins/rose-pine.lua b/.config/nvim/lua/plugins/rose-pine.lua new file mode 100644 index 0000000..a27b40a --- /dev/null +++ b/.config/nvim/lua/plugins/rose-pine.lua @@ -0,0 +1,7 @@ +return { + "rose-pine/nvim", + name = "rose-pine", + config = function () + vim.cmd.colorscheme("rose-pine") + end +} diff --git a/.config/nvim/lua/plugins/telescope-file-browser.lua b/.config/nvim/lua/plugins/telescope-file-browser.lua new file mode 100644 index 0000000..d80edb4 --- /dev/null +++ b/.config/nvim/lua/plugins/telescope-file-browser.lua @@ -0,0 +1,7 @@ +return { + "nvim-telescope/telescope-file-browser.nvim", + dependencies = { + "nvim-telescope/telescope.nvim", + "nvim-lua/plenary.nvim", + }, +} diff --git a/.config/nvim/lua/plugins/telescope.lua b/.config/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..871b03e --- /dev/null +++ b/.config/nvim/lua/plugins/telescope.lua @@ -0,0 +1,70 @@ +return { + "nvim-telescope/telescope.nvim", + version = "0.1.2", + dependencies = { "nvim-lua/plenary.nvim" }, + config = function() + local telescope = require("telescope") + local actions = require("telescope.actions") + local builtin = require("telescope.builtin") + local fb_actions = require "telescope".extensions.file_browser.actions + + local function telescope_buffer_dir() + return vim.fn.expand("%:p:h") + end + + telescope.setup({ + defaults = { + mappings = { + n = { + ['q'] = actions.close + } + } + }, + extensions = { + file_browser = { + theme = "dropdown", + hijack_netrw = true, + hidden = true, + mappings = { + ['i'] = { + [''] = function() vim.cmd("normal vbd") end, + [''] = function(bufnr) actions.move_selection_next(bufnr) end, + [''] = function(bufnr) actions.move_selection_previous(bufnr) end, + [''] = function(bufnr) actions.select_vertical(bufnr) end, + }, + ['n'] = { + ['N'] = fb_actions.create, + ['h'] = fb_actions.goto_parent_dir, + ['/'] = function() vim.cmd("startinsert") end, + ['D'] = fb_actions.remove, + [''] = function(bufnr) actions.select_vertical(bufnr) end, + [''] = function(bufnr) actions.toggle_all(bufnr) end, + } + } + }, + } + }) + + telescope.load_extension("file_browser") + + -- Set up keymaps specific to telescope + vim.keymap.set("n", ";f", function() + builtin.find_files({ no_ignore = false, hidden = true }) + end) + vim.keymap.set("n", ";g", builtin.git_files) + vim.keymap.set("n", "sf", + function() + telescope.extensions.file_browser.file_browser({ + path = "%:p:h", + cwd = telescope_buffer_dir(), + respect_gitignore = true, + hidden = true, + grouped = true, + previewer = false, + initial_mode = "normal", + layout_config = { height = 40 } + }) + end) + vim.keymap.set("n", ";h", builtin.help_tags) + end +} diff --git a/.config/nvim/lua/plugins/todo-comments.lua b/.config/nvim/lua/plugins/todo-comments.lua new file mode 100644 index 0000000..48dd949 --- /dev/null +++ b/.config/nvim/lua/plugins/todo-comments.lua @@ -0,0 +1,5 @@ +return { + "folke/todo-comments.nvim", + dependencies = { "nvim-lua/plenary.nvim" }, + config = {}, +} diff --git a/.config/nvim/lua/plugins/treesitter.lua b/.config/nvim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..ff78ca3 --- /dev/null +++ b/.config/nvim/lua/plugins/treesitter.lua @@ -0,0 +1,27 @@ +return { + 'nvim-treesitter/nvim-treesitter', + build = ":TSUpdate", + config = function() + local treesitter = require("nvim-treesitter.configs") + + treesitter.setup { + -- A list of parser names, or "all" + ensure_installed = { "vimdoc", "javascript", "typescript", "c", "lua", "rust" }, + + -- Install parsers synchronously (only applied to `ensure_installed`) + sync_install = false, + + -- Automatically install missing parsers when entering buffer + -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally + auto_install = true, + + highlight = { + enable = true, + }, + + context_commentstring = { + enable = true, + }, + } + end +} diff --git a/.config/nvim/lua/plugins/undotree.lua b/.config/nvim/lua/plugins/undotree.lua new file mode 100644 index 0000000..fe1b251 --- /dev/null +++ b/.config/nvim/lua/plugins/undotree.lua @@ -0,0 +1,22 @@ +return { + "mbbill/undotree", + keys = { + { "u", "UndotreeToggle", desc = "Toggle Undotree" }, + }, + config = function() + local has_persistent_undo = vim.api.nvim_call_function("has", { "persistent_undo" }) + + if has_persistent_undo then + local target_path = vim.api.nvim_call_function("expand", { "~/.undodir" }) + + local is_directory = vim.api.nvim_call_function("isdirectory", { target_path }) + + if not is_directory then + vim.api.nvim_call_function("mkdir", { target_path, "p", 0700 }) + end + + vim.opt.undodir = target_path + vim.opt.undofile = true + end + end +} From 1bf7a8bee0b5ab817e46d77e65a9d6cfba0dbb4b Mon Sep 17 00:00:00 2001 From: Juan Wu <46619361+juancwu@users.noreply.github.com> Date: Tue, 11 Jul 2023 22:12:29 -0400 Subject: [PATCH 18/19] in progress: add fzf, git, which-key --- .config/nvim/init.lua | 10 ++++++++- .config/nvim/lazy-lock.json | 18 +++++++++------ .config/nvim/lua/plugins/autotag.lua | 5 +++++ .config/nvim/lua/plugins/colorscheme.lua | 8 +++++++ .config/nvim/lua/plugins/floaterm.lua | 2 +- .config/nvim/lua/plugins/fzf.lua | 13 +++++++++++ .config/nvim/lua/plugins/git.lua | 28 ++++++++++++++++++++++++ .config/nvim/lua/plugins/lsp-zero.lua | 2 ++ .config/nvim/lua/plugins/rose-pine.lua | 7 ------ .config/nvim/lua/plugins/telescope.lua | 17 ++++++++++++-- .config/nvim/lua/plugins/treesitter.lua | 14 ++++++++++++ .config/nvim/lua/plugins/which-key.lua | 14 ++++++++++++ 12 files changed, 120 insertions(+), 18 deletions(-) create mode 100644 .config/nvim/lua/plugins/colorscheme.lua create mode 100644 .config/nvim/lua/plugins/fzf.lua create mode 100644 .config/nvim/lua/plugins/git.lua delete mode 100644 .config/nvim/lua/plugins/rose-pine.lua create mode 100644 .config/nvim/lua/plugins/which-key.lua diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 07dad03..d4b6baf 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -16,4 +16,12 @@ require("keymaps") require("clipboard") require("options") -require("lazy").setup("plugins") +require("lazy").setup({ + import = "plugins", + install = { + colorscheme = { "rose-pine" }, + } +}) + +-- set theme +vim.cmd.colorscheme("rose-pine") diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 9df48e8..7b3df22 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,19 +1,22 @@ { "Comment.nvim": { "branch": "master", "commit": "176e85eeb63f1a5970d6b88f1725039d85ca0055" }, - "LuaSnip": { "branch": "master", "commit": "a658ae2906344a1d2b9c507738e585cf68e685c7" }, + "LuaSnip": { "branch": "master", "commit": "45a4e899ca8f54936fe32ead6bba65f2a8d42e12" }, "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, - "gitsigns.nvim": { "branch": "main", "commit": "dc2962f7fce953a2a98e7c6d3d7fc4c1d1f66758" }, + "fzf": { "branch": "master", "commit": "0130f64934d2a3ac4f5639ed16cf3dbcfb38240b" }, + "fzf-lua": { "branch": "main", "commit": "359f3e9eccbc38a6158f57e75aa2a3c525abc476" }, + "git.nvim": { "branch": "main", "commit": "7a342e61f28e321ef08e00fca4be74ff3ef88335" }, + "gitsigns.nvim": { "branch": "main", "commit": "48c3ae8ec74cb83f9570ceb0c5ab8217db7a2220" }, "harpoon": { "branch": "master", "commit": "21f4c47c6803d64ddb934a5b314dcb1b8e7365dc" }, - "lazy.nvim": { "branch": "main", "commit": "5af331ea65418dc9361769891921fdee4bcc837a" }, + "lazy.nvim": { "branch": "main", "commit": "da8b00581a52f5f87ad2aba9f52171fda7491f18" }, "lsp-zero.nvim": { "branch": "v2.x", "commit": "7b9627c2cb50906993e194290b2e539c95dfdf47" }, "lualine.nvim": { "branch": "master", "commit": "05d78e9fd0cdfb4545974a5aa14b1be95a86e9c9" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "82685fdd0f67a694b244cb058b83761f54664d68" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "796008869e67ef27a5aa5ac44c08ce2a60b89f55" }, "mason.nvim": { "branch": "main", "commit": "5ad3e113b0c3fde3caba8630599373046f6197e8" }, "null-ls.nvim": { "branch": "main", "commit": "db09b6c691def0038c456551e4e2772186449f35" }, "nvim-autopairs": { "branch": "master", "commit": "e8f7dd7a72de3e7b6626c050a802000e69d53ff0" }, - "nvim-cmp": { "branch": "main", "commit": "2743dd989e9b932e1b4813a4927d7b84272a14e2" }, + "nvim-cmp": { "branch": "main", "commit": "c4e491a87eeacf0408902c32f031d802c7eafce8" }, "nvim-lspconfig": { "branch": "master", "commit": "deade69789089c3da15237697156334fb3e943f0" }, - "nvim-treesitter": { "branch": "master", "commit": "d9104a1d10023ed9e7eacf68639ad887425246eb" }, + "nvim-treesitter": { "branch": "master", "commit": "b4b94ec387525cb9df4b56eb1a8bf33231a0df47" }, "nvim-ts-autotag": { "branch": "main", "commit": "6be1192965df35f94b8ea6d323354f7dc7a557e4" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "7f625207f225eea97ef7a6abe7611e556c396d2f" }, "nvim-web-devicons": { "branch": "master", "commit": "9ab9b0b894b2388a9dbcdee5f00ce72e25d85bf9" }, @@ -23,5 +26,6 @@ "telescope.nvim": { "branch": "master", "commit": "776b509f80dd49d8205b9b0d94485568236d1192" }, "todo-comments.nvim": { "branch": "main", "commit": "09b0b17d824d2d56f02ff15967e8a2499a89c731" }, "undotree": { "branch": "master", "commit": "0e11ba7325efbbb3f3bebe06213afa3e7ec75131" }, - "vim-floaterm": { "branch": "master", "commit": "bd0aee3c861d613f56b85bd9eaffdcab459071fd" } + "vim-floaterm": { "branch": "master", "commit": "bcaeabf89a92a924031d471395054d84bd88ce2f" }, + "which-key.nvim": { "branch": "main", "commit": "d871f2b664afd5aed3dc1d1573bef2fb24ce0484" } } \ No newline at end of file diff --git a/.config/nvim/lua/plugins/autotag.lua b/.config/nvim/lua/plugins/autotag.lua index 5ac274b..e5d682f 100644 --- a/.config/nvim/lua/plugins/autotag.lua +++ b/.config/nvim/lua/plugins/autotag.lua @@ -1,6 +1,11 @@ return { "windwp/nvim-ts-autotag", dependencies = { "nvim-treesitter/nvim-treesitter", build = ':TSUpdate' }, + ft = { + "javascriptreact", + "typescriptreact", + "html" + }, config = function() local autotag = require('nvim-ts-autotag') autotag.setup() diff --git a/.config/nvim/lua/plugins/colorscheme.lua b/.config/nvim/lua/plugins/colorscheme.lua new file mode 100644 index 0000000..5c3e06f --- /dev/null +++ b/.config/nvim/lua/plugins/colorscheme.lua @@ -0,0 +1,8 @@ +return { + { + "rose-pine/nvim", + name = "rose-pine", + lazy = true, + priority = 1000, + }, +} diff --git a/.config/nvim/lua/plugins/floaterm.lua b/.config/nvim/lua/plugins/floaterm.lua index bd793d2..d88d42b 100644 --- a/.config/nvim/lua/plugins/floaterm.lua +++ b/.config/nvim/lua/plugins/floaterm.lua @@ -1,6 +1,6 @@ return { "voldikss/vim-floaterm", keys = { - { "gg", "FloatermNew lazygit", desc = "Open lazygit in a floating window" }, + { "gl", "FloatermNew lazygit", desc = "Open lazygit in a floating window" }, }, } diff --git a/.config/nvim/lua/plugins/fzf.lua b/.config/nvim/lua/plugins/fzf.lua new file mode 100644 index 0000000..37823bc --- /dev/null +++ b/.config/nvim/lua/plugins/fzf.lua @@ -0,0 +1,13 @@ +return { + "ibhagwan/fzf-lua", + -- optional for icon support + dependencies = { + "nvim-tree/nvim-web-devicons", + { "junegunn/fzf", build = "./install --bin" } + }, + config = function() + -- calling `setup` is optional for customization + require("fzf-lua").setup({}) + end, + enabled = true, +} diff --git a/.config/nvim/lua/plugins/git.lua b/.config/nvim/lua/plugins/git.lua new file mode 100644 index 0000000..4fc89c3 --- /dev/null +++ b/.config/nvim/lua/plugins/git.lua @@ -0,0 +1,28 @@ +return { + 'dinhhuy258/git.nvim', + keys = { + { "gb", "GitBlame", desc = "Open Git Blame" }, + { "gd", "GitDiff", desc = "Open Git Diff" }, + { "gs", "Git status", desc = "Open Git Status" } + }, + cmd = { + "Git", + "GitBlame", + "GitDiff", + }, + config = function() + local git = require('git') + + git.setup({ + default_keymaps = true, + keymaps = { + blame = "gb", + quit_blame = "q", + diff = "gd", + diff_close = "q", + }, + target_branch = "main", + + }) + end +} diff --git a/.config/nvim/lua/plugins/lsp-zero.lua b/.config/nvim/lua/plugins/lsp-zero.lua index 0c8f69d..abf46c6 100644 --- a/.config/nvim/lua/plugins/lsp-zero.lua +++ b/.config/nvim/lua/plugins/lsp-zero.lua @@ -25,6 +25,8 @@ return { lspzero.on_attach(function(client, bufnr) lspzero.default_keymaps({ buffer = bufnr }) + local current_dir = vim.fn.expand("%:p:h") + -- format with space + f vim.keymap.set("n", "f", "lua vim.lsp.buf.format()") end) diff --git a/.config/nvim/lua/plugins/rose-pine.lua b/.config/nvim/lua/plugins/rose-pine.lua deleted file mode 100644 index a27b40a..0000000 --- a/.config/nvim/lua/plugins/rose-pine.lua +++ /dev/null @@ -1,7 +0,0 @@ -return { - "rose-pine/nvim", - name = "rose-pine", - config = function () - vim.cmd.colorscheme("rose-pine") - end -} diff --git a/.config/nvim/lua/plugins/telescope.lua b/.config/nvim/lua/plugins/telescope.lua index 871b03e..2710b45 100644 --- a/.config/nvim/lua/plugins/telescope.lua +++ b/.config/nvim/lua/plugins/telescope.lua @@ -52,7 +52,8 @@ return { builtin.find_files({ no_ignore = false, hidden = true }) end) vim.keymap.set("n", ";g", builtin.git_files) - vim.keymap.set("n", "sf", + vim.keymap.set("n", ";h", builtin.help_tags) + vim.keymap.set("n", ";d", function() telescope.extensions.file_browser.file_browser({ path = "%:p:h", @@ -65,6 +66,18 @@ return { layout_config = { height = 40 } }) end) - vim.keymap.set("n", ";h", builtin.help_tags) + + local status, wk = pcall(require, "which-key"); + if status then + wk.register({ + [";"] = { + name = "Telescope", + f = { desc = "Search files in project" }, + d = { desc = "Open directory viewer" }, + g = { desc = "Search git files" }, + h = { desc = "Search help tags" }, + } + }) + end end } diff --git a/.config/nvim/lua/plugins/treesitter.lua b/.config/nvim/lua/plugins/treesitter.lua index ff78ca3..49202e9 100644 --- a/.config/nvim/lua/plugins/treesitter.lua +++ b/.config/nvim/lua/plugins/treesitter.lua @@ -1,6 +1,10 @@ return { 'nvim-treesitter/nvim-treesitter', build = ":TSUpdate", + event = { + "BufReadPost", + "BufNewFile" + }, config = function() local treesitter = require("nvim-treesitter.configs") @@ -22,6 +26,16 @@ return { context_commentstring = { enable = true, }, + + incremental_selection = { + enable = true, + keymaps = { + init_selection = 'c', + node_incremental = "", + scope_incremental = "", + node_decremental = "" + } + } } end } diff --git a/.config/nvim/lua/plugins/which-key.lua b/.config/nvim/lua/plugins/which-key.lua new file mode 100644 index 0000000..6642352 --- /dev/null +++ b/.config/nvim/lua/plugins/which-key.lua @@ -0,0 +1,14 @@ +return { + { + "folke/which-key.nvim", + event = "VeryLazy", + config = function() + vim.opt.timeout = true + vim.opt.timeoutlen = 300 + + local wk = require("which-key") + + wk.setup() + end, + } +} From 1898ac5c10c0e68da87c23db18a7c4c959388ac4 Mon Sep 17 00:00:00 2001 From: Juan Wu <46619361+juancwu@users.noreply.github.com> Date: Mon, 17 Jul 2023 13:32:24 -0400 Subject: [PATCH 19/19] new neovim configs --- .config/nvim/init.lua | 3 - .config/nvim/lazy-lock.json | 32 +++-- .config/nvim/lua/keymaps.lua | 12 +- .config/nvim/lua/options.lua | 16 +++ .config/nvim/lua/plugins/colorscheme.lua | 14 +- .config/nvim/lua/plugins/floaterm.lua | 2 +- .config/nvim/lua/plugins/fzf.lua | 5 +- .config/nvim/lua/plugins/git.lua | 7 +- .config/nvim/lua/plugins/lsp-zero.lua | 29 +++- .config/nvim/lua/plugins/lualine.lua | 10 +- .config/nvim/lua/plugins/neo-tree.lua | 70 ++++++++++ .config/nvim/lua/plugins/neodev.lua | 10 ++ .config/nvim/lua/plugins/nvim-dap-ui.lua | 21 +++ .../nvim/lua/plugins/nvim-dap-vscode-js.lua | 63 +++++++++ .config/nvim/lua/plugins/nvim-dap.lua | 78 +++++++++++ .config/nvim/lua/plugins/telescope-dap.lua | 6 + .../lua/plugins/telescope-file-browser.lua | 11 +- .../nvim/lua/plugins/telescope-fzf-native.lua | 5 + .config/nvim/lua/plugins/telescope.lua | 127 ++++++++++-------- .config/nvim/lua/plugins/treesitter.lua | 55 +++++++- 20 files changed, 466 insertions(+), 110 deletions(-) create mode 100644 .config/nvim/lua/plugins/neo-tree.lua create mode 100644 .config/nvim/lua/plugins/neodev.lua create mode 100644 .config/nvim/lua/plugins/nvim-dap-ui.lua create mode 100644 .config/nvim/lua/plugins/nvim-dap-vscode-js.lua create mode 100644 .config/nvim/lua/plugins/nvim-dap.lua create mode 100644 .config/nvim/lua/plugins/telescope-dap.lua create mode 100644 .config/nvim/lua/plugins/telescope-fzf-native.lua diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index d4b6baf..98954cc 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -22,6 +22,3 @@ require("lazy").setup({ colorscheme = { "rose-pine" }, } }) - --- set theme -vim.cmd.colorscheme("rose-pine") diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 7b3df22..a12ed3d 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -2,30 +2,38 @@ "Comment.nvim": { "branch": "master", "commit": "176e85eeb63f1a5970d6b88f1725039d85ca0055" }, "LuaSnip": { "branch": "master", "commit": "45a4e899ca8f54936fe32ead6bba65f2a8d42e12" }, "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, - "fzf": { "branch": "master", "commit": "0130f64934d2a3ac4f5639ed16cf3dbcfb38240b" }, - "fzf-lua": { "branch": "main", "commit": "359f3e9eccbc38a6158f57e75aa2a3c525abc476" }, + "fzf": { "branch": "master", "commit": "547e101f1d6bf326d286bac0fb3272738a92a67f" }, + "fzf-lua": { "branch": "main", "commit": "19732fdf9b8b038b6a5813b077b382ab2b48e094" }, "git.nvim": { "branch": "main", "commit": "7a342e61f28e321ef08e00fca4be74ff3ef88335" }, - "gitsigns.nvim": { "branch": "main", "commit": "48c3ae8ec74cb83f9570ceb0c5ab8217db7a2220" }, + "gitsigns.nvim": { "branch": "main", "commit": "5a04466685008f29c71fa5ec25d421deb1c83fea" }, "harpoon": { "branch": "master", "commit": "21f4c47c6803d64ddb934a5b314dcb1b8e7365dc" }, - "lazy.nvim": { "branch": "main", "commit": "da8b00581a52f5f87ad2aba9f52171fda7491f18" }, - "lsp-zero.nvim": { "branch": "v2.x", "commit": "7b9627c2cb50906993e194290b2e539c95dfdf47" }, + "lazy.nvim": { "branch": "main", "commit": "14d76aac4bd3ff07c1fca074c210f28f766a931e" }, + "lsp-zero.nvim": { "branch": "v2.x", "commit": "0b4c5966884e80c5100c04790defe1fd72d918aa" }, "lualine.nvim": { "branch": "master", "commit": "05d78e9fd0cdfb4545974a5aa14b1be95a86e9c9" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "796008869e67ef27a5aa5ac44c08ce2a60b89f55" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "828a538ac8419f586c010996aefa5df6eb7c250b" }, "mason.nvim": { "branch": "main", "commit": "5ad3e113b0c3fde3caba8630599373046f6197e8" }, + "neo-tree.nvim": { "branch": "v2.x", "commit": "7f6fa04dbd8e8c79d1af33bc90e856b65d8641da" }, + "nui.nvim": { "branch": "main", "commit": "d146966a423e60699b084eeb28489fe3b6427599" }, "null-ls.nvim": { "branch": "main", "commit": "db09b6c691def0038c456551e4e2772186449f35" }, - "nvim-autopairs": { "branch": "master", "commit": "e8f7dd7a72de3e7b6626c050a802000e69d53ff0" }, + "nvim-autopairs": { "branch": "master", "commit": "ae5b41ce880a6d850055e262d6dfebd362bb276e" }, "nvim-cmp": { "branch": "main", "commit": "c4e491a87eeacf0408902c32f031d802c7eafce8" }, - "nvim-lspconfig": { "branch": "master", "commit": "deade69789089c3da15237697156334fb3e943f0" }, - "nvim-treesitter": { "branch": "master", "commit": "b4b94ec387525cb9df4b56eb1a8bf33231a0df47" }, + "nvim-dap": { "branch": "master", "commit": "3bde6f786057fa29d8356559b2ae3a52d9317fba" }, + "nvim-dap-ui": { "branch": "master", "commit": "85b16ac2309d85c88577cd8ee1733ce52be8227e" }, + "nvim-dap-vscode-js": { "branch": "main", "commit": "03bd29672d7fab5e515fc8469b7d07cc5994bbf6" }, + "nvim-lspconfig": { "branch": "master", "commit": "4b26897a80c41eb2f116b271cbdcd4686fb52dd6" }, + "nvim-treesitter": { "branch": "master", "commit": "39f10b0b14184f746a0c9e7475c5ea81a9a812f6" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "52f1f3280d9092bfaee5c45be5962fabee3d9654" }, "nvim-ts-autotag": { "branch": "main", "commit": "6be1192965df35f94b8ea6d323354f7dc7a557e4" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "7f625207f225eea97ef7a6abe7611e556c396d2f" }, "nvim-web-devicons": { "branch": "master", "commit": "9ab9b0b894b2388a9dbcdee5f00ce72e25d85bf9" }, - "plenary.nvim": { "branch": "master", "commit": "bda256fab0eb66a15e8190937e417e6a14ee5d72" }, + "plenary.nvim": { "branch": "master", "commit": "1a6a7c929628566cf406aa7da1d048a1ddc7e9a8" }, "rose-pine": { "branch": "main", "commit": "932adb0d9351186db047302de021bb2976756a07" }, - "telescope-file-browser.nvim": { "branch": "master", "commit": "e03ff55962417b69c85ef41424079bb0580546ba" }, + "telescope-dap.nvim": { "branch": "master", "commit": "313d2ea12ae59a1ca51b62bf01fc941a983d9c9c" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "9bc8237565ded606e6c366a71c64c0af25cd7a50" }, "telescope.nvim": { "branch": "master", "commit": "776b509f80dd49d8205b9b0d94485568236d1192" }, "todo-comments.nvim": { "branch": "main", "commit": "09b0b17d824d2d56f02ff15967e8a2499a89c731" }, "undotree": { "branch": "master", "commit": "0e11ba7325efbbb3f3bebe06213afa3e7ec75131" }, "vim-floaterm": { "branch": "master", "commit": "bcaeabf89a92a924031d471395054d84bd88ce2f" }, - "which-key.nvim": { "branch": "main", "commit": "d871f2b664afd5aed3dc1d1573bef2fb24ce0484" } + "vscode-js-debug": { "branch": "main", "commit": "16b9a70171b94cfe4aafc49e991f93b87b8ffb77" }, + "which-key.nvim": { "branch": "main", "commit": "96e99913df649d45333a9ad625ad4c72d5e65fe1" } } \ No newline at end of file diff --git a/.config/nvim/lua/keymaps.lua b/.config/nvim/lua/keymaps.lua index 42b3e48..bc7e855 100644 --- a/.config/nvim/lua/keymaps.lua +++ b/.config/nvim/lua/keymaps.lua @@ -1,4 +1,5 @@ vim.g.mapleader = " " +vim.g.maplocalleader = " " -- easy escape vim.keymap.set("i", "", "", { noremap = true, silent = true }) @@ -32,7 +33,7 @@ vim.keymap.set("n", "q", "", { noremap = true }) vim.keymap.set("n", "q", "q", { noremap = true }) -- select and replace -vim.keymap.set("n", "s", [[:%s/\<\>//gI]]) +vim.keymap.set("n", "ss", [[:%s/\<\>//gI]]) -- no copy, delete line, for god sake... vim.keymap.set("n", "dd", "\"_dd") @@ -81,9 +82,8 @@ vim.keymap.set("i", "", "", { noremap = true }) vim.keymap.set("i", "", "", { noremap = true }) -- terminal keymaps -vim.keymap.set("t", "", "", { noremap = true }) -vim.keymap.set("t", "", "bd!", { noremap = true }) -vim.keymap.set("n", "", "termi", { noremap = true }) +vim.keymap.set("t", "", "", { noremap = true }) -- exit insert mode in terminal +vim.keymap.set("t", "", "bd!", { noremap = true }) -- terminate terminal session +vim.keymap.set("n", "", "termi", { noremap = true }) -- create new terminal session --- lazygit on floaterm -vim.keymap.set("n", "g", "FloatermNew lazygit", { noremap = true }) +vim.keymap.set({ 'n', 'v' }, "", "", { silent = true }) diff --git a/.config/nvim/lua/options.lua b/.config/nvim/lua/options.lua index 1cb7748..dc9d30b 100644 --- a/.config/nvim/lua/options.lua +++ b/.config/nvim/lua/options.lua @@ -42,3 +42,19 @@ vim.opt.termguicolors = true -- good shit, just take it -- activate persistent undo vim.opt.undofile = true + + +-- [[ highlight on yank ]] +local highligh_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) +vim.api.nvim_create_autocmd('TextYankPost', { + callback = function() + vim.highlight.on_yank() + end, + group = highligh_group, + pattern = '*', +}) + + +vim.opt.completeopt = 'menuone,noselect' + +vim.opt.breakindent = true diff --git a/.config/nvim/lua/plugins/colorscheme.lua b/.config/nvim/lua/plugins/colorscheme.lua index 5c3e06f..84c5d94 100644 --- a/.config/nvim/lua/plugins/colorscheme.lua +++ b/.config/nvim/lua/plugins/colorscheme.lua @@ -2,7 +2,19 @@ return { { "rose-pine/nvim", name = "rose-pine", - lazy = true, priority = 1000, + enabled = true, + config = function() + vim.cmd.colorscheme("rose-pine") + end + }, + { + -- Theme inspired by Atom + 'navarasu/onedark.nvim', + priority = 1000, + enabled = false, + config = function() + vim.cmd.colorscheme 'onedark' + end, }, } diff --git a/.config/nvim/lua/plugins/floaterm.lua b/.config/nvim/lua/plugins/floaterm.lua index d88d42b..2e17a3f 100644 --- a/.config/nvim/lua/plugins/floaterm.lua +++ b/.config/nvim/lua/plugins/floaterm.lua @@ -1,6 +1,6 @@ return { "voldikss/vim-floaterm", keys = { - { "gl", "FloatermNew lazygit", desc = "Open lazygit in a floating window" }, + { "lg", "FloatermNew lazygit", desc = "Open lazygit in a floating window" }, }, } diff --git a/.config/nvim/lua/plugins/fzf.lua b/.config/nvim/lua/plugins/fzf.lua index 37823bc..a9f3338 100644 --- a/.config/nvim/lua/plugins/fzf.lua +++ b/.config/nvim/lua/plugins/fzf.lua @@ -5,9 +5,6 @@ return { "nvim-tree/nvim-web-devicons", { "junegunn/fzf", build = "./install --bin" } }, - config = function() - -- calling `setup` is optional for customization - require("fzf-lua").setup({}) - end, + config = {}, enabled = true, } diff --git a/.config/nvim/lua/plugins/git.lua b/.config/nvim/lua/plugins/git.lua index 4fc89c3..2f8fcf3 100644 --- a/.config/nvim/lua/plugins/git.lua +++ b/.config/nvim/lua/plugins/git.lua @@ -1,9 +1,8 @@ return { 'dinhhuy258/git.nvim', keys = { - { "gb", "GitBlame", desc = "Open Git Blame" }, - { "gd", "GitDiff", desc = "Open Git Diff" }, - { "gs", "Git status", desc = "Open Git Status" } + { "gbl", "GitBlame", desc = "Open [G]it [Bl]ame" }, + { "gd", "GitDiff", desc = "Open [G]it [D]iff" }, }, cmd = { "Git", @@ -16,9 +15,7 @@ return { git.setup({ default_keymaps = true, keymaps = { - blame = "gb", quit_blame = "q", - diff = "gd", diff_close = "q", }, target_branch = "main", diff --git a/.config/nvim/lua/plugins/lsp-zero.lua b/.config/nvim/lua/plugins/lsp-zero.lua index abf46c6..474b04b 100644 --- a/.config/nvim/lua/plugins/lsp-zero.lua +++ b/.config/nvim/lua/plugins/lsp-zero.lua @@ -20,15 +20,38 @@ return { config = function() local lspzero = require("lsp-zero") - lspzero.preset("recommended") + lspzero.preset({}) lspzero.on_attach(function(client, bufnr) - lspzero.default_keymaps({ buffer = bufnr }) + lspzero.default_keymaps({ + buffer = bufnr, + omit = { + 'gr' + }, + }) + + function nmap(key, action, desc) + vim.keymap.set( + "n", + key, + action, + { + desc = "LSP: " .. desc, + } + ) + end + + nmap("[d", "lua vim.diagnostic.goto_prev()", "Goto Prev Diagnostic"); + nmap("]d", "lua vim.diagnostic.goto_next()", "Goto Next Diagnostic") local current_dir = vim.fn.expand("%:p:h") + -- vim.keymap.set('n', 'gr', 'Telescope lsp_references', { buffer = true }) + -- format with space + f - vim.keymap.set("n", "f", "lua vim.lsp.buf.format()") + -- vim.keymap.set("n", "fb", "lua vim.lsp.buf.format()", + -- { desc = "[F]ormat [B]uffer" }) + nmap("fb", "lua vim.lsp.buf.format()", "[F]ormat [B]uffer") end) lspzero.ensure_installed({ diff --git a/.config/nvim/lua/plugins/lualine.lua b/.config/nvim/lua/plugins/lualine.lua index 5c0c025..e994ed1 100644 --- a/.config/nvim/lua/plugins/lualine.lua +++ b/.config/nvim/lua/plugins/lualine.lua @@ -1,20 +1,22 @@ return { "nvim-lualine/lualine.nvim", dependencies = { "nvim-tree/nvim-web-devicons", lazy = true }, - config = function () + config = function() local lualine = require('lualine') lualine.setup { options = { - icons_enabled = true, - section_separators = { + icons_enabled = false, + --[[ section_separators = { left = '', right = '' }, component_separators = { left = '', right = '' - }, + }, ]] + section_separators = '', + component_separators = '|', disabled_filetypes = {} }, sections = { diff --git a/.config/nvim/lua/plugins/neo-tree.lua b/.config/nvim/lua/plugins/neo-tree.lua new file mode 100644 index 0000000..7f9aa5f --- /dev/null +++ b/.config/nvim/lua/plugins/neo-tree.lua @@ -0,0 +1,70 @@ +return { + "nvim-neo-tree/neo-tree.nvim", + branch = "v2.x", + cmd = { "Neotree" }, + keys = { + { "fs", "NeoTreeFloatToggle", desc = "Toggle [F]ile [S]ystem Floating Menu" }, + { "", "NeoTreeFocusToggle", desc = "Open Side File System" } + }, + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + "MunifTanjim/nui.nvim", + }, + config = { + use_default_mappings = true, + mappings = { + [""] = { + "toggle_node", + nowait = true, -- disable `nowait` if you have existing combos starting with this char that you want to use + }, + ["<2-LeftMouse>"] = "open", + [""] = "open", + [""] = "cancel", -- close preview or floating neo-tree window + ["P"] = { "toggle_preview", config = { use_float = true } }, + ["l"] = "focus_preview", + ["O"] = "open_split", + ["o"] = "open_vsplit", + ["S"] = "none", + ["s"] = "none", + -- ["S"] = "split_with_window_picker", + -- ["s"] = "vsplit_with_window_picker", + ["t"] = "open_tabnew", + -- [""] = "open_drop", + -- ["t"] = "open_tab_drop", + ["w"] = "open_with_window_picker", + --["P"] = "toggle_preview", -- enter preview mode, which shows the current node without focusing + ["C"] = "close_node", + -- ['C'] = 'close_all_subnodes', + ["z"] = "close_all_nodes", + --["Z"] = "expand_all_nodes", + ["a"] = { + "add", + -- this command supports BASH style brace expansion ("x{a,b,c}" -> xa,xb,xc). see `:h neo-tree-file-actions` for details + -- some commands may take optional config options, see `:h neo-tree-mappings` for details + config = { + show_path = "none" -- "none", "relative", "absolute" + } + }, + ["A"] = "add_directory", -- also accepts the optional config.show_path option like "add". this also supports BASH style brace expansion. + ["d"] = "delete", + ["r"] = "rename", + ["y"] = "copy_to_clipboard", + ["x"] = "cut_to_clipboard", + ["p"] = "paste_from_clipboard", + ["c"] = "copy", -- takes text input for destination, also accepts the optional config.show_path option like "add": + -- ["c"] = { + -- "copy", + -- config = { + -- show_path = "none" -- "none", "relative", "absolute" + -- } + --} + ["m"] = "move", -- takes text input for destination, also accepts the optional config.show_path option like "add". + ["q"] = "close_window", + ["R"] = "refresh", + ["?"] = "show_help", + ["<"] = "prev_source", + [">"] = "next_source", + } + } +} diff --git a/.config/nvim/lua/plugins/neodev.lua b/.config/nvim/lua/plugins/neodev.lua new file mode 100644 index 0000000..27874e5 --- /dev/null +++ b/.config/nvim/lua/plugins/neodev.lua @@ -0,0 +1,10 @@ +return { + "folke/neodev.nvim", + enabled = false, + config = { + library = { + plugins = true, + types = true, + } + } +} diff --git a/.config/nvim/lua/plugins/nvim-dap-ui.lua b/.config/nvim/lua/plugins/nvim-dap-ui.lua new file mode 100644 index 0000000..ccfdf18 --- /dev/null +++ b/.config/nvim/lua/plugins/nvim-dap-ui.lua @@ -0,0 +1,21 @@ +return { + "rcarriga/nvim-dap-ui", + dependencies = { + 'mfussenegger/nvim-dap', + }, + config = function() + local dap, dapui = require("dap"), require("dapui") + dapui.setup({ + width = 50, + }) + dap.listeners.after.event_initialized['dapui_config'] = function() + dapui.open() + end + dap.listeners.before.event_terminated['dapui_config'] = function() + dapui.close() + end + dap.listeners.before.event_exited['dapui_config'] = function() + dapui.close() + end + end +} diff --git a/.config/nvim/lua/plugins/nvim-dap-vscode-js.lua b/.config/nvim/lua/plugins/nvim-dap-vscode-js.lua new file mode 100644 index 0000000..be85f7c --- /dev/null +++ b/.config/nvim/lua/plugins/nvim-dap-vscode-js.lua @@ -0,0 +1,63 @@ +local DEBUGGER_PATH = vim.fn.stdpath("data") .. "/lazy/vscode-js-debug" + +return { + { + "microsoft/vscode-js-debug", + lazy = true, + build = "npm install --legacy-peer-deps && npx gulp vsDebugServerBundle && mv dist out", + }, + { + 'mxsdev/nvim-dap-vscode-js', + dependencies = { + "mfussenegger/nvim-dap", + }, + config = function() + local dapVsCode = require("dap-vscode-js") + dapVsCode.setup({ + node_path = "node", + debugger_path = DEBUGGER_PATH, + adapters = { + "pwa-node", + "pwa-chrome", + "pwa-msedge", + "pwa-extensionHost", + "node-terminal", + } + }) + + for _, language in ipairs({ "typescript", "javascript" }) do + require("dap").configurations[language] = { + { + type = "pwa-node", + request = "launch", + name = "Launch file (node)", + program = "${file}", + cwd = "${workspaceFolder}", + }, + { + type = "pwa-node", + request = "attach", + name = "Attach (node)", + processId = require('dap.utils').pick_process, + cwd = "${workspaceFolder}", + }, + { + type = "pwa-node", + request = "launch", + name = "Debug Jest Tests", + trace = true, + runtimeExecutable = "node", + runtimeArgs = { + "./node_modules/jest/bin/jest.js", + "--runInBand", + }, + rootPath = "${workspaceFolder}", + cwd = "${workspaceFolder}", + console = "integratedTerminal", + internalConsoleOptions = "neverOpen", + }, + } + end + end + } +} diff --git a/.config/nvim/lua/plugins/nvim-dap.lua b/.config/nvim/lua/plugins/nvim-dap.lua new file mode 100644 index 0000000..dc3d8d8 --- /dev/null +++ b/.config/nvim/lua/plugins/nvim-dap.lua @@ -0,0 +1,78 @@ +return { + 'mfussenegger/nvim-dap', + config = function() + local status, wk = pcall(require, "which-key") + + local dap_breakpoints = { + breakpoint = { + text = "", + texthl = "LspDiagnosticsSignError", + linehl = "", + numhl = "", + }, + rejected = { + text = "", + texthl = "LspDiagnosticsSignHint", + linehl = "", + numhl = "", + }, + stopped = { + text = "", + texthl = "LspDiagnosticsSignInformation", + linehl = "DiagnosticUnderlineInfo", + numhl = "LspDiagnosticsSignInformation", + }, + } + + vim.fn.sign_define("DapBreakpoint", dap_breakpoints.breakpoint) + vim.fn.sign_define("DapStopped", dap_breakpoints.stopped) + vim.fn.sign_define("DapBreakpointRejected", dap_breakpoints.rejected) + + if not status then + local function nmap(key, action, desc) + vim.keymap.set( + "n", + "d" .. key, + action, + { + desc = "[D]AP: " .. desc, + noremap = true, + nowait = false, + silent = true + } + ) + end + + nmap("c", "lua require'dap'.continue()", "[C]ontinue") + nmap("b", "lua require'dap'.toggle_breakpoint()", "Toggle [B]reakpoint") + nmap("i", "lua require'dap'.step_into()", "Step [I]nto") + nmap("o", "lua require'dap'.step_over()", "Step [O]ver") + nmap("u", "lua require'dap'.step_out()", "[U] Step Out") + nmap("x", "lua require'dap'.terminate()", "[T]erminate") + nmap("q", "lua require'dap'.close()", "[Q]uit") + else + local keymap = { + d = { + name = "DAP", + c = { "lua require'dap'.continue()", "[C]ontinue" }, + b = { "lua require'dap'.toggle_breakpoint()", "Toggle [B]reakpoint" }, + i = { "lua require'dap'.step_into()", "Step [I]nto" }, + o = { "lua require'dap'.step_over()", "Step [O]ver" }, + u = { "lua require'dap'.step_out()", "[U] Step Out" }, + x = { "lua require'dap'.terminate()", "[T]erminate" }, + q = { "lua require'dap'.close()", "[Q]uit" }, + }, + } + + local opts = { + mode = "n", + prefix = "", + buffer = nil, + silent = true, + noremap = true, + nowait = false, + } + wk.register(keymap, opts) + end + end +} diff --git a/.config/nvim/lua/plugins/telescope-dap.lua b/.config/nvim/lua/plugins/telescope-dap.lua new file mode 100644 index 0000000..f365713 --- /dev/null +++ b/.config/nvim/lua/plugins/telescope-dap.lua @@ -0,0 +1,6 @@ +return { + "nvim-telescope/telescope-dap.nvim", + dependencies = { + 'mfussenegger/nvim-dap' + }, +} diff --git a/.config/nvim/lua/plugins/telescope-file-browser.lua b/.config/nvim/lua/plugins/telescope-file-browser.lua index d80edb4..4419301 100644 --- a/.config/nvim/lua/plugins/telescope-file-browser.lua +++ b/.config/nvim/lua/plugins/telescope-file-browser.lua @@ -1,7 +1,8 @@ return { - "nvim-telescope/telescope-file-browser.nvim", - dependencies = { - "nvim-telescope/telescope.nvim", - "nvim-lua/plenary.nvim", - }, + "nvim-telescope/telescope-file-browser.nvim", + dependencies = { + "nvim-telescope/telescope.nvim", + "nvim-lua/plenary.nvim", + }, + enabled = false, } diff --git a/.config/nvim/lua/plugins/telescope-fzf-native.lua b/.config/nvim/lua/plugins/telescope-fzf-native.lua new file mode 100644 index 0000000..0822423 --- /dev/null +++ b/.config/nvim/lua/plugins/telescope-fzf-native.lua @@ -0,0 +1,5 @@ +return { + 'nvim-telescope/telescope-fzf-native.nvim', + build = 'make', + enabled = true, +} diff --git a/.config/nvim/lua/plugins/telescope.lua b/.config/nvim/lua/plugins/telescope.lua index 2710b45..87beb48 100644 --- a/.config/nvim/lua/plugins/telescope.lua +++ b/.config/nvim/lua/plugins/telescope.lua @@ -6,11 +6,11 @@ return { local telescope = require("telescope") local actions = require("telescope.actions") local builtin = require("telescope.builtin") - local fb_actions = require "telescope".extensions.file_browser.actions - - local function telescope_buffer_dir() - return vim.fn.expand("%:p:h") - end + -- local fb_actions = require "telescope".extensions.file_browser.actions + -- + -- local function telescope_buffer_dir() + -- return vim.fn.expand("%:p:h") + -- end telescope.setup({ defaults = { @@ -20,64 +20,73 @@ return { } } }, - extensions = { - file_browser = { - theme = "dropdown", - hijack_netrw = true, - hidden = true, - mappings = { - ['i'] = { - [''] = function() vim.cmd("normal vbd") end, - [''] = function(bufnr) actions.move_selection_next(bufnr) end, - [''] = function(bufnr) actions.move_selection_previous(bufnr) end, - [''] = function(bufnr) actions.select_vertical(bufnr) end, - }, - ['n'] = { - ['N'] = fb_actions.create, - ['h'] = fb_actions.goto_parent_dir, - ['/'] = function() vim.cmd("startinsert") end, - ['D'] = fb_actions.remove, - [''] = function(bufnr) actions.select_vertical(bufnr) end, - [''] = function(bufnr) actions.toggle_all(bufnr) end, - } - } - }, - } + -- extensions = { + -- file_browser = { + -- theme = "dropdown", + -- hijack_netrw = true, + -- hidden = true, + -- mappings = { + -- ['i'] = { + -- [''] = function() vim.cmd("normal vbd") end, + -- [''] = function(bufnr) actions.move_selection_next(bufnr) end, + -- [''] = function(bufnr) actions.move_selection_previous(bufnr) end, + -- [''] = function(bufnr) actions.select_vertical(bufnr) end, + -- }, + -- ['n'] = { + -- ['N'] = fb_actions.create, + -- ['h'] = fb_actions.goto_parent_dir, + -- ['/'] = function() vim.cmd("startinsert") end, + -- ['D'] = fb_actions.remove, + -- [''] = function(bufnr) actions.select_vertical(bufnr) end, + -- [''] = function(bufnr) actions.toggle_all(bufnr) end, + -- } + -- } + -- }, + -- } }) - telescope.load_extension("file_browser") + -- pcall(telescope.load_extension, "file_browser") + pcall(telescope.load_extension, "fzf") + pcall(telescope.load_extension, "dap") - -- Set up keymaps specific to telescope - vim.keymap.set("n", ";f", function() + -- Builtin pickers + vim.keymap.set("n", "sf", function() builtin.find_files({ no_ignore = false, hidden = true }) - end) - vim.keymap.set("n", ";g", builtin.git_files) - vim.keymap.set("n", ";h", builtin.help_tags) - vim.keymap.set("n", ";d", - function() - telescope.extensions.file_browser.file_browser({ - path = "%:p:h", - cwd = telescope_buffer_dir(), - respect_gitignore = true, - hidden = true, - grouped = true, - previewer = false, - initial_mode = "normal", - layout_config = { height = 40 } - }) - end) + end, { desc = "[S]earch [F]iles" }) + vim.keymap.set("n", "sh", builtin.help_tags, { desc = "[S]earch [H]elp Tags" }) + vim.keymap.set("n", "sb", builtin.buffers, { desc = "[S]earch [B]uffers" }) + vim.keymap.set("n", "sw", builtin.grep_string, { desc = "[S]earch [W]ord" }) + vim.keymap.set("n", "sg", builtin.live_grep, { desc = "[S]earch by [G]rep" }) + vim.keymap.set("n", "sd", builtin.diagnostics, { desc = "[S]earch [D]iagnostics" }) + vim.keymap.set("n", "gr", builtin.lsp_references, { desc = "[G]o to [R]eferences", noremap = true }) - local status, wk = pcall(require, "which-key"); - if status then - wk.register({ - [";"] = { - name = "Telescope", - f = { desc = "Search files in project" }, - d = { desc = "Open directory viewer" }, - g = { desc = "Search git files" }, - h = { desc = "Search help tags" }, - } - }) - end + -- Git pickers + vim.keymap.set("n", "gf", builtin.git_files, { desc = "Search [G]it [F]iles" }) + vim.keymap.set("n", "gs", builtin.git_status, { desc = "List [G]it [S]tatus" }) + vim.keymap.set("n", "gh", builtin.git_stash, { desc = "List [G]it [S]tash" }) + vim.keymap.set("n", "gbb", builtin.git_branches, { desc = "List [G]it [B]ranches" }) + vim.keymap.set("n", "gc", builtin.git_bcommits, { desc = "List Buffer [G]it [C]ommits" }) + + -- File Browser Ext + -- vim.keymap.set("n", "od", + -- function() + -- telescope.extensions.file_browser.file_browser({ + -- path = "%:p:h", + -- cwd = telescope_buffer_dir(), + -- respect_gitignore = true, + -- hidden = true, + -- grouped = true, + -- previewer = false, + -- initial_mode = "normal", + -- layout_config = { height = 40 } + -- }) + -- end, { desc = "[O]pen [D]irectory" }) + + vim.keymap.set('n', '/', function() + builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown({ + winblend = 10, + previewer = false, + })) + end, { desc = '[/] Fuzzily serach in current buffer' }) end } diff --git a/.config/nvim/lua/plugins/treesitter.lua b/.config/nvim/lua/plugins/treesitter.lua index 49202e9..6a92ef9 100644 --- a/.config/nvim/lua/plugins/treesitter.lua +++ b/.config/nvim/lua/plugins/treesitter.lua @@ -5,28 +5,25 @@ return { "BufReadPost", "BufNewFile" }, + dependencies = { + "nvim-treesitter/nvim-treesitter-textobjects", + }, config = function() local treesitter = require("nvim-treesitter.configs") treesitter.setup { -- A list of parser names, or "all" ensure_installed = { "vimdoc", "javascript", "typescript", "c", "lua", "rust" }, - -- Install parsers synchronously (only applied to `ensure_installed`) sync_install = false, - -- Automatically install missing parsers when entering buffer - -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally auto_install = true, - highlight = { enable = true, }, - context_commentstring = { enable = true, }, - incremental_selection = { enable = true, keymaps = { @@ -35,7 +32,51 @@ return { scope_incremental = "", node_decremental = "" } - } + }, + textobjects = { + select = { + enable = true, + lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ['aa'] = '@parameter.outer', + ['ia'] = '@parameter.inner', + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['ac'] = '@class.outer', + ['ic'] = '@class.inner', + }, + }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + [']m'] = '@function.outer', + [']]'] = '@class.outer', + }, + goto_next_end = { + [']M'] = '@function.outer', + [']['] = '@class.outer', + }, + goto_previous_start = { + ['[m'] = '@function.outer', + ['[['] = '@class.outer', + }, + goto_previous_end = { + ['[M'] = '@function.outer', + ['[]'] = '@class.outer', + }, + }, + swap = { + enable = true, + swap_next = { + [']'] = '@parameter.inner', + }, + swap_previous = { + ['['] = '@parameter.inner', + }, + }, + }, } end }