diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index b7105ed..a12ed3d 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,27 +1,39 @@ { "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": "547e101f1d6bf326d286bac0fb3272738a92a67f" }, + "fzf-lua": { "branch": "main", "commit": "19732fdf9b8b038b6a5813b077b382ab2b48e094" }, + "git.nvim": { "branch": "main", "commit": "7a342e61f28e321ef08e00fca4be74ff3ef88335" }, + "gitsigns.nvim": { "branch": "main", "commit": "5a04466685008f29c71fa5ec25d421deb1c83fea" }, "harpoon": { "branch": "master", "commit": "21f4c47c6803d64ddb934a5b314dcb1b8e7365dc" }, - "lazy.nvim": { "branch": "main", "commit": "3ad55ae678876516156cca2f361c51f7952a924b" }, - "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": "82685fdd0f67a694b244cb058b83761f54664d68" }, + "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-cmp": { "branch": "main", "commit": "2743dd989e9b932e1b4813a4927d7b84272a14e2" }, - "nvim-lspconfig": { "branch": "master", "commit": "deade69789089c3da15237697156334fb3e943f0" }, - "nvim-treesitter": { "branch": "master", "commit": "d9104a1d10023ed9e7eacf68639ad887425246eb" }, + "nvim-autopairs": { "branch": "master", "commit": "ae5b41ce880a6d850055e262d6dfebd362bb276e" }, + "nvim-cmp": { "branch": "main", "commit": "c4e491a87eeacf0408902c32f031d802c7eafce8" }, + "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": "bd0aee3c861d613f56b85bd9eaffdcab459071fd" } + "vim-floaterm": { "branch": "master", "commit": "bcaeabf89a92a924031d471395054d84bd88ce2f" }, + "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/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 index 42b3e48..a65811e 100644 --- a/.config/nvim/lua/keymaps.lua +++ b/.config/nvim/lua/keymaps.lua @@ -1,4 +1,10 @@ vim.g.mapleader = " " +vim.g.maplocalleader = " " + +-- 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 }) -- easy escape vim.keymap.set("i", "", "", { noremap = true, silent = true }) @@ -32,7 +38,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 +87,11 @@ 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 + +vim.keymap.set({ 'n', 'v' }, "", "", { silent = 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 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/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..84c5d94 --- /dev/null +++ b/.config/nvim/lua/plugins/colorscheme.lua @@ -0,0 +1,20 @@ +return { + { + "rose-pine/nvim", + name = "rose-pine", + 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 bd793d2..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 = { - { "gg", "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 new file mode 100644 index 0000000..a9f3338 --- /dev/null +++ b/.config/nvim/lua/plugins/fzf.lua @@ -0,0 +1,10 @@ +return { + "ibhagwan/fzf-lua", + -- optional for icon support + dependencies = { + "nvim-tree/nvim-web-devicons", + { "junegunn/fzf", build = "./install --bin" } + }, + config = {}, + enabled = true, +} diff --git a/.config/nvim/lua/plugins/git.lua b/.config/nvim/lua/plugins/git.lua new file mode 100644 index 0000000..2f8fcf3 --- /dev/null +++ b/.config/nvim/lua/plugins/git.lua @@ -0,0 +1,25 @@ +return { + 'dinhhuy258/git.nvim', + keys = { + { "gbl", "GitBlame", desc = "Open [G]it [Bl]ame" }, + { "gd", "GitDiff", desc = "Open [G]it [D]iff" }, + }, + cmd = { + "Git", + "GitBlame", + "GitDiff", + }, + config = function() + local git = require('git') + + git.setup({ + default_keymaps = true, + keymaps = { + quit_blame = "q", + 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..474b04b 100644 --- a/.config/nvim/lua/plugins/lsp-zero.lua +++ b/.config/nvim/lua/plugins/lsp-zero.lua @@ -20,13 +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 871b03e..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,51 +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", "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, { 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 }) + + -- 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 ff78ca3..6a92ef9 100644 --- a/.config/nvim/lua/plugins/treesitter.lua +++ b/.config/nvim/lua/plugins/treesitter.lua @@ -1,27 +1,82 @@ return { 'nvim-treesitter/nvim-treesitter', build = ":TSUpdate", + event = { + "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 = { + init_selection = 'c', + node_incremental = "", + 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 } 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, + } +}