From 8738fcdde984b87e55f301532f1bd7fdee1d44cc 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] 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 +}