diff options
| author | leiyu3 <s444814187@gmail.com> | 2026-02-24 15:26:45 -0500 |
|---|---|---|
| committer | leiyu3 <s444814187@gmail.com> | 2026-02-24 15:26:45 -0500 |
| commit | 25bc82f7acde5fe11ee41ed3530607c219083d9a (patch) | |
| tree | 2267899fa85ead83e8cbc14a53621540c6d70d28 /.config/nvim | |
| parent | b8fcc11c9b7f77b88e0880ececa735536d938f8d (diff) | |
| download | dotfiles-master.tar.gz dotfiles-master.zip | |
Diffstat (limited to '.config/nvim')
| -rw-r--r-- | .config/nvim/init.lua | 221 | ||||
| -rw-r--r-- | .config/nvim/lazy-lock.json | 16 | ||||
| -rw-r--r-- | .config/nvim/lua/config/lazy.lua | 35 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/cmp-hledger.lua | 3 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/cmp-nvim-lsp.lua | 3 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/lualine.lua | 4 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/mason-lspconfig.lua | 11 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/mason.lua | 4 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/nvim-cmp.lua | 3 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/nvim-lspconfig.lua | 13 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/telescope.lua | 8 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/tokyonight.lua | 6 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/tree-sitter.lua | 5 |
13 files changed, 332 insertions, 0 deletions
diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua new file mode 100644 index 0000000..36ad9d3 --- /dev/null +++ b/.config/nvim/init.lua | |||
| @@ -0,0 +1,221 @@ | |||
| 1 | -- hi Normal guibg=NONE ctermbg=NONE | ||
| 2 | -- | ||
| 3 | require("config.lazy") | ||
| 4 | |||
| 5 | vim.g.mapleader = ' ' | ||
| 6 | |||
| 7 | vim.o.number = true | ||
| 8 | vim.o.relativenumber = true | ||
| 9 | vim.o.ignorecase = true | ||
| 10 | vim.o.smartcase = true | ||
| 11 | vim.o.tabstop = 2 | ||
| 12 | vim.o.shiftwidth = 2 | ||
| 13 | vim.o.expandtab = true | ||
| 14 | vim.o.scrolloff = 5 | ||
| 15 | |||
| 16 | vim.keymap.set('n', '<leader>a', ':keepjumps normal! ggVG<cr>') | ||
| 17 | |||
| 18 | vim.o.clipboard = "unnamedplus" | ||
| 19 | |||
| 20 | |||
| 21 | require("nvim-treesitter").setup{ | ||
| 22 | indent = { enable = true }, | ||
| 23 | highlight = { | ||
| 24 | enable = true, | ||
| 25 | additional_vim_regex_highlighting = false, | ||
| 26 | }, | ||
| 27 | auto_install = false, | ||
| 28 | ensure_installed = { | ||
| 29 | "bash", | ||
| 30 | "c", | ||
| 31 | "diff", | ||
| 32 | "html", | ||
| 33 | "javascript", | ||
| 34 | "json", | ||
| 35 | "lua", | ||
| 36 | "markdown", | ||
| 37 | "markdown_inline", | ||
| 38 | "python", | ||
| 39 | "toml", | ||
| 40 | "yaml", | ||
| 41 | }, | ||
| 42 | } | ||
| 43 | |||
| 44 | vim.api.nvim_create_autocmd('FileType', { | ||
| 45 | pattern = { '<filetype>' }, | ||
| 46 | callback = function() vim.treesitter.start() end, | ||
| 47 | }) | ||
| 48 | |||
| 49 | |||
| 50 | local builtin = require('telescope.builtin') | ||
| 51 | vim.keymap.set('n', '<C-p>', builtin.find_files, { desc = 'Telescope find files' }) | ||
| 52 | vim.keymap.set('n', '<leader>s', builtin.live_grep, { desc = 'Telescope live grep' }) | ||
| 53 | vim.keymap.set('n', '<leader>f', builtin.git_files, { desc = 'Telescope git files' }) | ||
| 54 | |||
| 55 | vim.cmd[[colorscheme tokyonight-night]] | ||
| 56 | |||
| 57 | require('lualine').setup { | ||
| 58 | options = { | ||
| 59 | icons_enabled = true, | ||
| 60 | theme = 'auto', | ||
| 61 | component_separators = { left = '', right = ''}, | ||
| 62 | section_separators = { left = '', right = ''}, | ||
| 63 | disabled_filetypes = { | ||
| 64 | statusline = {}, | ||
| 65 | winbar = {}, | ||
| 66 | }, | ||
| 67 | ignore_focus = {}, | ||
| 68 | always_divide_middle = true, | ||
| 69 | always_show_tabline = true, | ||
| 70 | globalstatus = false, | ||
| 71 | refresh = { | ||
| 72 | statusline = 1000, | ||
| 73 | tabline = 1000, | ||
| 74 | winbar = 1000, | ||
| 75 | refresh_time = 16, -- ~60fps | ||
| 76 | events = { | ||
| 77 | 'WinEnter', | ||
| 78 | 'BufEnter', | ||
| 79 | 'BufWritePost', | ||
| 80 | 'SessionLoadPost', | ||
| 81 | 'FileChangedShellPost', | ||
| 82 | 'VimResized', | ||
| 83 | 'Filetype', | ||
| 84 | 'CursorMoved', | ||
| 85 | 'CursorMovedI', | ||
| 86 | 'ModeChanged', | ||
| 87 | }, | ||
| 88 | } | ||
| 89 | }, | ||
| 90 | sections = { | ||
| 91 | lualine_a = {'mode'}, | ||
| 92 | lualine_b = {'branch', 'diff', 'diagnostics'}, | ||
| 93 | lualine_c = {'filename'}, | ||
| 94 | lualine_x = {'encoding', 'fileformat', 'filetype'}, | ||
| 95 | lualine_y = {'progress'}, | ||
| 96 | lualine_z = {'location'} | ||
| 97 | }, | ||
| 98 | inactive_sections = { | ||
| 99 | lualine_a = {}, | ||
| 100 | lualine_b = {}, | ||
| 101 | lualine_c = {'filename'}, | ||
| 102 | lualine_x = {'location'}, | ||
| 103 | lualine_y = {}, | ||
| 104 | lualine_z = {} | ||
| 105 | }, | ||
| 106 | tabline = {}, | ||
| 107 | winbar = {}, | ||
| 108 | inactive_winbar = {}, | ||
| 109 | extensions = {} | ||
| 110 | } | ||
| 111 | |||
| 112 | -- An example nvim-lspconfig capabilities setting | ||
| 113 | |||
| 114 | vim.lsp.enable("pyright") | ||
| 115 | vim.lsp.enable("lua_ls") | ||
| 116 | vim.lsp.enable("ts_ls") | ||
| 117 | vim.lsp.enable("clangd") | ||
| 118 | |||
| 119 | vim.keymap.set('n', '<space>d', vim.diagnostic.open_float) | ||
| 120 | |||
| 121 | |||
| 122 | -- Set up nvim-cmp. | ||
| 123 | local cmp = require'cmp' | ||
| 124 | |||
| 125 | cmp.setup({ | ||
| 126 | snippet = { | ||
| 127 | -- REQUIRED - you must specify a snippet engine | ||
| 128 | expand = function(args) | ||
| 129 | -- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. | ||
| 130 | -- require('luasnip').lsp_expand(args.body) -- For `luasnip` users. | ||
| 131 | -- require('snippy').expand_snippet(args.body) -- For `snippy` users. | ||
| 132 | -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. | ||
| 133 | vim.snippet.expand(args.body) -- For native neovim snippets (Neovim v0.10+) | ||
| 134 | |||
| 135 | -- For `mini.snippets` users: | ||
| 136 | -- local insert = MiniSnippets.config.expand.insert or MiniSnippets.default_insert | ||
| 137 | -- insert({ body = args.body }) -- Insert at cursor | ||
| 138 | -- cmp.resubscribe({ "TextChangedI", "TextChangedP" }) | ||
| 139 | -- require("cmp.config").set_onetime({ sources = {} }) | ||
| 140 | end, | ||
| 141 | }, | ||
| 142 | window = { | ||
| 143 | completion = cmp.config.window.bordered(), | ||
| 144 | documentation = cmp.config.window.bordered(), | ||
| 145 | }, | ||
| 146 | mapping = cmp.mapping.preset.insert({ | ||
| 147 | ['<C-b>'] = cmp.mapping.scroll_docs(-4), | ||
| 148 | ['<C-f>'] = cmp.mapping.scroll_docs(4), | ||
| 149 | ['<C-Space>'] = cmp.mapping.complete(), | ||
| 150 | ['<C-e>'] = cmp.mapping.abort(), | ||
| 151 | ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. | ||
| 152 | }), | ||
| 153 | sources = cmp.config.sources({ | ||
| 154 | { name = 'nvim_lsp' }, | ||
| 155 | -- { name = 'vsnip' }, -- For vsnip users. | ||
| 156 | -- { name = 'luasnip' }, -- For luasnip users. | ||
| 157 | -- { name = 'ultisnips' }, -- For ultisnips users. | ||
| 158 | -- { name = 'snippy' }, -- For snippy users. | ||
| 159 | }, { | ||
| 160 | { name = 'buffer' }, | ||
| 161 | }) | ||
| 162 | }) | ||
| 163 | |||
| 164 | -- To use git you need to install the plugin petertriho/cmp-git and uncomment lines below | ||
| 165 | -- Set configuration for specific filetype. | ||
| 166 | --[[ cmp.setup.filetype('gitcommit', { | ||
| 167 | sources = cmp.config.sources({ | ||
| 168 | { name = 'git' }, | ||
| 169 | }, { | ||
| 170 | { name = 'buffer' }, | ||
| 171 | }) | ||
| 172 | }) | ||
| 173 | require("cmp_git").setup() ]]-- | ||
| 174 | |||
| 175 | -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). | ||
| 176 | cmp.setup.cmdline({ '/', '?' }, { | ||
| 177 | mapping = cmp.mapping.preset.cmdline(), | ||
| 178 | sources = { | ||
| 179 | { name = 'buffer' } | ||
| 180 | } | ||
| 181 | }) | ||
| 182 | |||
| 183 | -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). | ||
| 184 | cmp.setup.cmdline(':', { | ||
| 185 | mapping = cmp.mapping.preset.cmdline(), | ||
| 186 | sources = cmp.config.sources({ | ||
| 187 | { name = 'path' } | ||
| 188 | }, { | ||
| 189 | { name = 'cmdline' } | ||
| 190 | }), | ||
| 191 | matching = { disallow_symbol_nonprefix_matching = false } | ||
| 192 | }) | ||
| 193 | |||
| 194 | -- Set up lspconfig. | ||
| 195 | local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) | ||
| 196 | -- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled. | ||
| 197 | vim.lsp.config("markdown_oxide", { | ||
| 198 | -- Ensure that dynamicRegistration is enabled! This allows the LS to take into account actions like the | ||
| 199 | -- Create Unresolved File code action, resolving completions for unindexed code blocks, ... | ||
| 200 | capabilities = vim.tbl_deep_extend( | ||
| 201 | 'force', | ||
| 202 | capabilities, | ||
| 203 | { | ||
| 204 | workspace = { | ||
| 205 | didChangeWatchedFiles = { | ||
| 206 | dynamicRegistration = true, | ||
| 207 | }, | ||
| 208 | }, | ||
| 209 | } | ||
| 210 | ), | ||
| 211 | on_attach = on_attach -- configure your on attach config | ||
| 212 | }) | ||
| 213 | vim.lsp.enable('markdown_oxide') | ||
| 214 | |||
| 215 | require('cmp').setup { | ||
| 216 | sources = { | ||
| 217 | { | ||
| 218 | name = 'hledger', | ||
| 219 | } | ||
| 220 | } | ||
| 221 | } | ||
diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json new file mode 100644 index 0000000..f6a474c --- /dev/null +++ b/.config/nvim/lazy-lock.json | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | { | ||
| 2 | "cmp-hledger": { "branch": "main", "commit": "ea2211cdd4f5d171ad2bdb0d66197173ce384ddd" }, | ||
| 3 | "cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" }, | ||
| 4 | "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, | ||
| 5 | "lualine.nvim": { "branch": "master", "commit": "47f91c416daef12db467145e16bed5bbfe00add8" }, | ||
| 6 | "mason-lspconfig.nvim": { "branch": "main", "commit": "6c4830e37743b060d13c9269394176aea6a0fbc8" }, | ||
| 7 | "mason.nvim": { "branch": "main", "commit": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65" }, | ||
| 8 | "nvim-cmp": { "branch": "main", "commit": "da88697d7f45d16852c6b2769dc52387d1ddc45f" }, | ||
| 9 | "nvim-lspconfig": { "branch": "master", "commit": "b7dcde3e6195b43476ae799720b177aedc16d44c" }, | ||
| 10 | "nvim-treesitter": { "branch": "main", "commit": "d660b7c002f3922b6bb3da47206645488a698426" }, | ||
| 11 | "nvim-web-devicons": { "branch": "master", "commit": "746ffbb17975ebd6c40142362eee1b0249969c5c" }, | ||
| 12 | "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, | ||
| 13 | "telescope-fzf-native.nvim": { "branch": "main", "commit": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c" }, | ||
| 14 | "telescope.nvim": { "branch": "master", "commit": "3333a52ff548ba0a68af6d8da1e54f9cd96e9179" }, | ||
| 15 | "tokyonight.nvim": { "branch": "main", "commit": "5da1b76e64daf4c5d410f06bcb6b9cb640da7dfd" } | ||
| 16 | } | ||
diff --git a/.config/nvim/lua/config/lazy.lua b/.config/nvim/lua/config/lazy.lua new file mode 100644 index 0000000..f5ee74c --- /dev/null +++ b/.config/nvim/lua/config/lazy.lua | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | -- Bootstrap lazy.nvim | ||
| 2 | local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" | ||
| 3 | if not (vim.uv or vim.loop).fs_stat(lazypath) then | ||
| 4 | local lazyrepo = "https://github.com/folke/lazy.nvim.git" | ||
| 5 | local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) | ||
| 6 | if vim.v.shell_error ~= 0 then | ||
| 7 | vim.api.nvim_echo({ | ||
| 8 | { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, | ||
| 9 | { out, "WarningMsg" }, | ||
| 10 | { "\nPress any key to exit..." }, | ||
| 11 | }, true, {}) | ||
| 12 | vim.fn.getchar() | ||
| 13 | os.exit(1) | ||
| 14 | end | ||
| 15 | end | ||
| 16 | vim.opt.rtp:prepend(lazypath) | ||
| 17 | |||
| 18 | -- Make sure to setup `mapleader` and `maplocalleader` before | ||
| 19 | -- loading lazy.nvim so that mappings are correct. | ||
| 20 | -- This is also a good place to setup other settings (vim.opt) | ||
| 21 | vim.g.mapleader = " " | ||
| 22 | vim.g.maplocalleader = "\\" | ||
| 23 | |||
| 24 | -- Setup lazy.nvim | ||
| 25 | require("lazy").setup({ | ||
| 26 | spec = { | ||
| 27 | -- import your plugins | ||
| 28 | { import = "plugins" }, | ||
| 29 | }, | ||
| 30 | -- Configure any other settings here. See the documentation for more details. | ||
| 31 | -- colorscheme that will be used when installing plugins. | ||
| 32 | install = { colorscheme = { "habamax" } }, | ||
| 33 | -- automatically check for plugin updates | ||
| 34 | checker = { enabled = true }, | ||
| 35 | }) | ||
diff --git a/.config/nvim/lua/plugins/cmp-hledger.lua b/.config/nvim/lua/plugins/cmp-hledger.lua new file mode 100644 index 0000000..d8b406d --- /dev/null +++ b/.config/nvim/lua/plugins/cmp-hledger.lua | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | return { | ||
| 2 | 'kirasok/cmp-hledger' | ||
| 3 | } | ||
diff --git a/.config/nvim/lua/plugins/cmp-nvim-lsp.lua b/.config/nvim/lua/plugins/cmp-nvim-lsp.lua new file mode 100644 index 0000000..cbebd75 --- /dev/null +++ b/.config/nvim/lua/plugins/cmp-nvim-lsp.lua | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | return { | ||
| 2 | 'hrsh7th/cmp-nvim-lsp' | ||
| 3 | } | ||
diff --git a/.config/nvim/lua/plugins/lualine.lua b/.config/nvim/lua/plugins/lualine.lua new file mode 100644 index 0000000..5f69610 --- /dev/null +++ b/.config/nvim/lua/plugins/lualine.lua | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | return { | ||
| 2 | 'nvim-lualine/lualine.nvim', | ||
| 3 | dependencies = { 'nvim-tree/nvim-web-devicons' } | ||
| 4 | } | ||
diff --git a/.config/nvim/lua/plugins/mason-lspconfig.lua b/.config/nvim/lua/plugins/mason-lspconfig.lua new file mode 100644 index 0000000..b5512e6 --- /dev/null +++ b/.config/nvim/lua/plugins/mason-lspconfig.lua | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | return { | ||
| 2 | "mason-org/mason-lspconfig.nvim", | ||
| 3 | opts = { | ||
| 4 | ensure_installed = { | ||
| 5 | "lua_ls", | ||
| 6 | -- "pyright", | ||
| 7 | "clangd", | ||
| 8 | -- "ts_ls", | ||
| 9 | }, | ||
| 10 | }, | ||
| 11 | } | ||
diff --git a/.config/nvim/lua/plugins/mason.lua b/.config/nvim/lua/plugins/mason.lua new file mode 100644 index 0000000..0949c15 --- /dev/null +++ b/.config/nvim/lua/plugins/mason.lua | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | return { | ||
| 2 | "mason-org/mason.nvim", | ||
| 3 | opts = {}, | ||
| 4 | } | ||
diff --git a/.config/nvim/lua/plugins/nvim-cmp.lua b/.config/nvim/lua/plugins/nvim-cmp.lua new file mode 100644 index 0000000..e9d946a --- /dev/null +++ b/.config/nvim/lua/plugins/nvim-cmp.lua | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | return { | ||
| 2 | "hrsh7th/nvim-cmp" | ||
| 3 | } | ||
diff --git a/.config/nvim/lua/plugins/nvim-lspconfig.lua b/.config/nvim/lua/plugins/nvim-lspconfig.lua new file mode 100644 index 0000000..2088263 --- /dev/null +++ b/.config/nvim/lua/plugins/nvim-lspconfig.lua | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | return { | ||
| 2 | "neovim/nvim-lspconfig", | ||
| 3 | config = function() | ||
| 4 | local lspconfig = require("lspconfig") | ||
| 5 | |||
| 6 | -- lspconfig.lua_ls.setup({}) | ||
| 7 | -- lspconfig.pyright.setup({}) | ||
| 8 | -- lspconfig.ts_ls.setup({}) | ||
| 9 | -- lspconfig.rust_analyzer.setup({}) | ||
| 10 | -- lspconfig.clangd.setup({}) | ||
| 11 | -- lspconfig.markdown_oxide.setup({}) | ||
| 12 | end | ||
| 13 | } | ||
diff --git a/.config/nvim/lua/plugins/telescope.lua b/.config/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..fef8e18 --- /dev/null +++ b/.config/nvim/lua/plugins/telescope.lua | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | return { | ||
| 2 | 'nvim-telescope/telescope.nvim', version = '*', | ||
| 3 | dependencies = { | ||
| 4 | 'nvim-lua/plenary.nvim', | ||
| 5 | -- optional but recommended | ||
| 6 | { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' }, | ||
| 7 | } | ||
| 8 | } | ||
diff --git a/.config/nvim/lua/plugins/tokyonight.lua b/.config/nvim/lua/plugins/tokyonight.lua new file mode 100644 index 0000000..3e6a862 --- /dev/null +++ b/.config/nvim/lua/plugins/tokyonight.lua | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | return { | ||
| 2 | "folke/tokyonight.nvim", | ||
| 3 | lazy = false, | ||
| 4 | priority = 1000, | ||
| 5 | opts = {}, | ||
| 6 | } | ||
diff --git a/.config/nvim/lua/plugins/tree-sitter.lua b/.config/nvim/lua/plugins/tree-sitter.lua new file mode 100644 index 0000000..e78bd71 --- /dev/null +++ b/.config/nvim/lua/plugins/tree-sitter.lua | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | return { | ||
| 2 | "nvim-treesitter/nvim-treesitter", | ||
| 3 | lazy = false, | ||
| 4 | build = ":TSUpdate", | ||
| 5 | } | ||
