From 25bc82f7acde5fe11ee41ed3530607c219083d9a Mon Sep 17 00:00:00 2001 From: leiyu3 Date: Tue, 24 Feb 2026 15:26:45 -0500 Subject: neovim, foot --- .config/nvim/init.lua | 221 +++++++++++++++++++++++++++ .config/nvim/lazy-lock.json | 16 ++ .config/nvim/lua/config/lazy.lua | 35 +++++ .config/nvim/lua/plugins/cmp-hledger.lua | 3 + .config/nvim/lua/plugins/cmp-nvim-lsp.lua | 3 + .config/nvim/lua/plugins/lualine.lua | 4 + .config/nvim/lua/plugins/mason-lspconfig.lua | 11 ++ .config/nvim/lua/plugins/mason.lua | 4 + .config/nvim/lua/plugins/nvim-cmp.lua | 3 + .config/nvim/lua/plugins/nvim-lspconfig.lua | 13 ++ .config/nvim/lua/plugins/telescope.lua | 8 + .config/nvim/lua/plugins/tokyonight.lua | 6 + .config/nvim/lua/plugins/tree-sitter.lua | 5 + 13 files changed, 332 insertions(+) create mode 100644 .config/nvim/init.lua create mode 100644 .config/nvim/lazy-lock.json create mode 100644 .config/nvim/lua/config/lazy.lua create mode 100644 .config/nvim/lua/plugins/cmp-hledger.lua create mode 100644 .config/nvim/lua/plugins/cmp-nvim-lsp.lua create mode 100644 .config/nvim/lua/plugins/lualine.lua create mode 100644 .config/nvim/lua/plugins/mason-lspconfig.lua create mode 100644 .config/nvim/lua/plugins/mason.lua create mode 100644 .config/nvim/lua/plugins/nvim-cmp.lua create mode 100644 .config/nvim/lua/plugins/nvim-lspconfig.lua create mode 100644 .config/nvim/lua/plugins/telescope.lua create mode 100644 .config/nvim/lua/plugins/tokyonight.lua create mode 100644 .config/nvim/lua/plugins/tree-sitter.lua (limited to '.config/nvim') 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 @@ +-- hi Normal guibg=NONE ctermbg=NONE +-- +require("config.lazy") + +vim.g.mapleader = ' ' + +vim.o.number = true +vim.o.relativenumber = true +vim.o.ignorecase = true +vim.o.smartcase = true +vim.o.tabstop = 2 +vim.o.shiftwidth = 2 +vim.o.expandtab = true +vim.o.scrolloff = 5 + +vim.keymap.set('n', 'a', ':keepjumps normal! ggVG') + +vim.o.clipboard = "unnamedplus" + + +require("nvim-treesitter").setup{ + indent = { enable = true }, + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + }, + auto_install = false, + ensure_installed = { + "bash", + "c", + "diff", + "html", + "javascript", + "json", + "lua", + "markdown", + "markdown_inline", + "python", + "toml", + "yaml", + }, +} + +vim.api.nvim_create_autocmd('FileType', { + pattern = { '' }, + callback = function() vim.treesitter.start() end, +}) + + +local builtin = require('telescope.builtin') +vim.keymap.set('n', '', builtin.find_files, { desc = 'Telescope find files' }) +vim.keymap.set('n', 's', builtin.live_grep, { desc = 'Telescope live grep' }) +vim.keymap.set('n', 'f', builtin.git_files, { desc = 'Telescope git files' }) + +vim.cmd[[colorscheme tokyonight-night]] + +require('lualine').setup { + options = { + icons_enabled = true, + theme = 'auto', + component_separators = { left = '', right = ''}, + section_separators = { left = '', right = ''}, + disabled_filetypes = { + statusline = {}, + winbar = {}, + }, + ignore_focus = {}, + always_divide_middle = true, + always_show_tabline = true, + globalstatus = false, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + refresh_time = 16, -- ~60fps + events = { + 'WinEnter', + 'BufEnter', + 'BufWritePost', + 'SessionLoadPost', + 'FileChangedShellPost', + 'VimResized', + 'Filetype', + 'CursorMoved', + 'CursorMovedI', + 'ModeChanged', + }, + } + }, + sections = { + lualine_a = {'mode'}, + lualine_b = {'branch', 'diff', 'diagnostics'}, + lualine_c = {'filename'}, + lualine_x = {'encoding', 'fileformat', 'filetype'}, + lualine_y = {'progress'}, + lualine_z = {'location'} + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = {'filename'}, + lualine_x = {'location'}, + lualine_y = {}, + lualine_z = {} + }, + tabline = {}, + winbar = {}, + inactive_winbar = {}, + extensions = {} +} + +-- An example nvim-lspconfig capabilities setting + +vim.lsp.enable("pyright") +vim.lsp.enable("lua_ls") +vim.lsp.enable("ts_ls") +vim.lsp.enable("clangd") + +vim.keymap.set('n', 'd', vim.diagnostic.open_float) + + +-- Set up nvim-cmp. +local cmp = require'cmp' + +cmp.setup({ +snippet = { +-- REQUIRED - you must specify a snippet engine +expand = function(args) +-- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. +-- require('luasnip').lsp_expand(args.body) -- For `luasnip` users. +-- require('snippy').expand_snippet(args.body) -- For `snippy` users. +-- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. +vim.snippet.expand(args.body) -- For native neovim snippets (Neovim v0.10+) + +-- For `mini.snippets` users: +-- local insert = MiniSnippets.config.expand.insert or MiniSnippets.default_insert +-- insert({ body = args.body }) -- Insert at cursor +-- cmp.resubscribe({ "TextChangedI", "TextChangedP" }) +-- require("cmp.config").set_onetime({ sources = {} }) +end, +}, +window = { +completion = cmp.config.window.bordered(), +documentation = cmp.config.window.bordered(), +}, +mapping = cmp.mapping.preset.insert({ +[''] = cmp.mapping.scroll_docs(-4), +[''] = cmp.mapping.scroll_docs(4), +[''] = cmp.mapping.complete(), +[''] = cmp.mapping.abort(), +[''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. +}), +sources = cmp.config.sources({ +{ name = 'nvim_lsp' }, +-- { name = 'vsnip' }, -- For vsnip users. +-- { name = 'luasnip' }, -- For luasnip users. +-- { name = 'ultisnips' }, -- For ultisnips users. +-- { name = 'snippy' }, -- For snippy users. +}, { +{ name = 'buffer' }, +}) +}) + +-- To use git you need to install the plugin petertriho/cmp-git and uncomment lines below +-- Set configuration for specific filetype. +--[[ cmp.setup.filetype('gitcommit', { +sources = cmp.config.sources({ +{ name = 'git' }, +}, { +{ name = 'buffer' }, +}) +}) +require("cmp_git").setup() ]]-- + +-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline({ '/', '?' }, { +mapping = cmp.mapping.preset.cmdline(), +sources = { +{ name = 'buffer' } +} +}) + +-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline(':', { +mapping = cmp.mapping.preset.cmdline(), +sources = cmp.config.sources({ +{ name = 'path' } +}, { +{ name = 'cmdline' } +}), +matching = { disallow_symbol_nonprefix_matching = false } +}) + +-- Set up lspconfig. +local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) +-- Replace with each lsp server you've enabled. +vim.lsp.config("markdown_oxide", { + -- Ensure that dynamicRegistration is enabled! This allows the LS to take into account actions like the + -- Create Unresolved File code action, resolving completions for unindexed code blocks, ... + capabilities = vim.tbl_deep_extend( + 'force', + capabilities, + { + workspace = { + didChangeWatchedFiles = { + dynamicRegistration = true, + }, + }, + } + ), + on_attach = on_attach -- configure your on attach config +}) +vim.lsp.enable('markdown_oxide') + +require('cmp').setup { + sources = { + { + name = 'hledger', + } + } +} 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 @@ +{ + "cmp-hledger": { "branch": "main", "commit": "ea2211cdd4f5d171ad2bdb0d66197173ce384ddd" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" }, + "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, + "lualine.nvim": { "branch": "master", "commit": "47f91c416daef12db467145e16bed5bbfe00add8" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "6c4830e37743b060d13c9269394176aea6a0fbc8" }, + "mason.nvim": { "branch": "main", "commit": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65" }, + "nvim-cmp": { "branch": "main", "commit": "da88697d7f45d16852c6b2769dc52387d1ddc45f" }, + "nvim-lspconfig": { "branch": "master", "commit": "b7dcde3e6195b43476ae799720b177aedc16d44c" }, + "nvim-treesitter": { "branch": "main", "commit": "d660b7c002f3922b6bb3da47206645488a698426" }, + "nvim-web-devicons": { "branch": "master", "commit": "746ffbb17975ebd6c40142362eee1b0249969c5c" }, + "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c" }, + "telescope.nvim": { "branch": "master", "commit": "3333a52ff548ba0a68af6d8da1e54f9cd96e9179" }, + "tokyonight.nvim": { "branch": "main", "commit": "5da1b76e64daf4c5d410f06bcb6b9cb640da7dfd" } +} 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 @@ +-- Bootstrap lazy.nvim +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) + +-- Make sure to setup `mapleader` and `maplocalleader` before +-- loading lazy.nvim so that mappings are correct. +-- This is also a good place to setup other settings (vim.opt) +vim.g.mapleader = " " +vim.g.maplocalleader = "\\" + +-- Setup lazy.nvim +require("lazy").setup({ + spec = { + -- import your plugins + { import = "plugins" }, + }, + -- Configure any other settings here. See the documentation for more details. + -- colorscheme that will be used when installing plugins. + install = { colorscheme = { "habamax" } }, + -- automatically check for plugin updates + checker = { enabled = true }, +}) 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 @@ +return { + 'kirasok/cmp-hledger' +} 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 @@ +return { + 'hrsh7th/cmp-nvim-lsp' +} 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 @@ +return { + 'nvim-lualine/lualine.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' } +} 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 @@ +return { + "mason-org/mason-lspconfig.nvim", + opts = { + ensure_installed = { + "lua_ls", + -- "pyright", + "clangd", + -- "ts_ls", + }, + }, +} 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 @@ +return { + "mason-org/mason.nvim", + opts = {}, +} 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 @@ +return { + "hrsh7th/nvim-cmp" +} 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 @@ +return { + "neovim/nvim-lspconfig", + config = function() + local lspconfig = require("lspconfig") + + -- lspconfig.lua_ls.setup({}) + -- lspconfig.pyright.setup({}) + -- lspconfig.ts_ls.setup({}) + -- lspconfig.rust_analyzer.setup({}) + -- lspconfig.clangd.setup({}) + -- lspconfig.markdown_oxide.setup({}) + end +} 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 @@ +return { + 'nvim-telescope/telescope.nvim', version = '*', + dependencies = { + 'nvim-lua/plenary.nvim', + -- optional but recommended + { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' }, + } +} 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 @@ +return { + "folke/tokyonight.nvim", + lazy = false, + priority = 1000, + opts = {}, +} 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 @@ +return { + "nvim-treesitter/nvim-treesitter", + lazy = false, + build = ":TSUpdate", +} -- cgit v1.2.3