From 1302056eddd9a69ea2d0ffdf8bedd8582fb5a907 Mon Sep 17 00:00:00 2001 From: cryxtalix Date: Fri, 8 May 2026 03:43:16 +0800 Subject: Update --- .config/nvim_pack/lua/configs/basic.lua | 83 +++++++++++++++++++++++ .config/nvim_pack/lua/configs/lsp.lua | 48 +++++++++++++ .config/nvim_pack/lua/configs/vim-plug.lua | 8 +++ .config/nvim_pack/lua/plugins/marks.lua | 11 +++ .config/nvim_pack/lua/plugins/mason.lua | 10 +++ .config/nvim_pack/lua/plugins/render-markdown.lua | 8 +++ .config/nvim_pack/lua/plugins/rustaceanvim.lua | 53 +++++++++++++++ 7 files changed, 221 insertions(+) create mode 100644 .config/nvim_pack/lua/configs/basic.lua create mode 100644 .config/nvim_pack/lua/configs/lsp.lua create mode 100644 .config/nvim_pack/lua/configs/vim-plug.lua create mode 100644 .config/nvim_pack/lua/plugins/marks.lua create mode 100644 .config/nvim_pack/lua/plugins/mason.lua create mode 100644 .config/nvim_pack/lua/plugins/render-markdown.lua create mode 100644 .config/nvim_pack/lua/plugins/rustaceanvim.lua (limited to '.config/nvim_pack/lua') diff --git a/.config/nvim_pack/lua/configs/basic.lua b/.config/nvim_pack/lua/configs/basic.lua new file mode 100644 index 0000000..b39412c --- /dev/null +++ b/.config/nvim_pack/lua/configs/basic.lua @@ -0,0 +1,83 @@ +----------- +-- Basic -- +----------- +vim.g.mapleader = " " +vim.opt.mouse = '' +vim.opt.wrap = true +vim.opt.number = true +vim.opt.relativenumber = true +vim.opt.laststatus = 2 +vim.opt.hlsearch = true +vim.opt.incsearch = true +-- Directory for swap files +vim.opt.directory = vim.fn.expand("~/.local/share/nvim/swap//") +-- Search into subfolders +-- Provides tab completion for file related tasks +vim.opt.path:append '**' +-- Display all matching files when we tab complete +vim.opt.wildmenu = true +vim.cmd("filetype plugin on") +vim.api.nvim_set_keymap('v', '', '"+y', { noremap = true, silent = true }) + +------------------------------------ +-- Native Neovim tabs and windows -- +------------------------------------ +vim.keymap.set('n', 'f', 'Explore', { desc = 'Open Neotree' }) +vim.keymap.set("n", 'c',function() + vim.cmd("Tex") + vim.cmd("wincmd r") +end, { desc = "Open tab"}) +vim.keymap.set("n", 'v', function() + vim.cmd("Vex") + vim.cmd("wincmd x") + vim.cmd("wincmd l") + vim.cmd("enew") +end, { desc = "Open vertical split" }) +vim.keymap.set("n", 'h', function() + vim.cmd("Sex") + vim.cmd("wincmd x") + vim.cmd("wincmd j") +end, { desc = "Open horizontal split" }) +-- Open terminal +local term_buf = nil +vim.keymap.set('n', 't', function() + if term_buf and vim.api.nvim_buf_is_valid(term_buf) then + -- Reuse existing terminal + vim.cmd('rightbelow vsplit') + vim.cmd('buffer ' .. term_buf) + else + -- Create a new terminal + vim.cmd('rightbelow vsplit | terminal') + term_buf = vim.api.nvim_get_current_buf() + end + vim.cmd('startinsert') +end, { desc = 'Open terminal in vertical split' }) +vim.keymap.set('t', '', [[:q]], { desc = 'Exit terminal mode' }) +vim.keymap.set('n', '', 'tabnext +', { desc = 'Switch next tab' }) +vim.keymap.set('n', '', 'tabnext -', { desc = 'Switch prev tab' }) +vim.keymap.set('n', '', 'tabmove -1', { desc = 'Move current tab left' }) +vim.keymap.set('n', '', 'tabmove +1', { desc = 'Move current tab right' }) +vim.keymap.set('n', '', 'wincmd k', { desc = 'Move cursor to window above' }) +vim.keymap.set('n', '', 'wincmd j', { desc = 'Move cursor to window below' }) +vim.keymap.set('n', '', 'wincmd h', { desc = 'Move cursor to window left' }) +vim.keymap.set('n', '', 'wincmd l', { desc = 'Move cursor to window right' }) + +----------------- +-- Diagnostics -- +----------------- +vim.diagnostic.config({ + virtual_text = false, -- Disable inline text diagnostics + signs = true, -- Keep signs in the sign column + update_in_insert = false, + underline = true, + severity_sort = true, +}) + +-- Show diagnostics on hover +vim.o.updatetime = 250 -- Faster update time for hover +vim.api.nvim_create_autocmd("CursorHold", { + pattern = "*", + callback = function() + vim.diagnostic.open_float(nil, { focus = false, scope = "cursor" }) + end, +}) diff --git a/.config/nvim_pack/lua/configs/lsp.lua b/.config/nvim_pack/lua/configs/lsp.lua new file mode 100644 index 0000000..7acbeba --- /dev/null +++ b/.config/nvim_pack/lua/configs/lsp.lua @@ -0,0 +1,48 @@ +-- Language server for specified languages +-- Hover with 'K' +-- Goto definition with :Goto +-- Open code action with :Codeact + +local servers = { + "lua_ls", "bashls", "clangd", "marksman", "pyright", "lemminx", +} + +vim.pack.add({ + { + src = "https://github.com/mason-org/mason.nvim.git", + version = 'main', + }, + { + src = "https://github.com/mason-org/mason-lspconfig.nvim.git", + version = 'main', + }, +}) + +require("mason").setup({}) +require("mason-lspconfig").setup({ + ensure_installed = servers, + automatic_installation = true, + automatic_enable = true, +}) + +-- Key mapping +-- Hover for definition +vim.keymap.set('n', 'K', vim.lsp.buf.hover, {}) + +-- Move to definition +vim.api.nvim_create_user_command( + "Goto", + function() + vim.lsp.buf.definition() + end, + {} +) + +-- Code action +vim.api.nvim_create_user_command( + "Codeact", + function() + vim.lsp.buf.code_action() + end, + {} +) diff --git a/.config/nvim_pack/lua/configs/vim-plug.lua b/.config/nvim_pack/lua/configs/vim-plug.lua new file mode 100644 index 0000000..01620e1 --- /dev/null +++ b/.config/nvim_pack/lua/configs/vim-plug.lua @@ -0,0 +1,8 @@ +vim.api.nvim_create_user_command( + "Update", + function() + vim.pack.update() + end, + {} +) + diff --git a/.config/nvim_pack/lua/plugins/marks.lua b/.config/nvim_pack/lua/plugins/marks.lua new file mode 100644 index 0000000..841d390 --- /dev/null +++ b/.config/nvim_pack/lua/plugins/marks.lua @@ -0,0 +1,11 @@ +vim.pack.add({ + { + src = 'https://github.com/chentoast/marks.nvim.git', + version = 'main', + }, +}) + +require("marks").setup({ + event = "VeryLazy", + opts = {}, +}) diff --git a/.config/nvim_pack/lua/plugins/mason.lua b/.config/nvim_pack/lua/plugins/mason.lua new file mode 100644 index 0000000..c085313 --- /dev/null +++ b/.config/nvim_pack/lua/plugins/mason.lua @@ -0,0 +1,10 @@ +vim.pack.add({ + { + src = "https://github.com/mason-org/mason.nvim.git", + version = 'main', + }, + { + src = "https://github.com/mason-org/mason-lspconfig.nvim.git", + version = 'main', + }, +}) diff --git a/.config/nvim_pack/lua/plugins/render-markdown.lua b/.config/nvim_pack/lua/plugins/render-markdown.lua new file mode 100644 index 0000000..3f2a800 --- /dev/null +++ b/.config/nvim_pack/lua/plugins/render-markdown.lua @@ -0,0 +1,8 @@ +vim.pack.add({ + 'https://github.com/nvim-treesitter/nvim-treesitter', + 'https://github.com/nvim-mini/mini.nvim', -- if you use the mini.nvim suite + -- 'https://github.com/nvim-mini/mini.icons', -- if you use standalone mini plugins + -- 'https://github.com/nvim-tree/nvim-web-devicons', -- if you prefer nvim-web-devicons + 'https://github.com/MeanderingProgrammer/render-markdown.nvim', +}) +require('render-markdown').setup({}) -- only mandatory if you want to set custom options diff --git a/.config/nvim_pack/lua/plugins/rustaceanvim.lua b/.config/nvim_pack/lua/plugins/rustaceanvim.lua new file mode 100644 index 0000000..dee1dc1 --- /dev/null +++ b/.config/nvim_pack/lua/plugins/rustaceanvim.lua @@ -0,0 +1,53 @@ +vim.pack.add({ + { + src = 'https://github.com/mrcjkb/rustaceanvim.git', + version = 'master', + lazy = false, -- This plugin is already lazy + }, +}) + +vim.g.rustaceanvim = { + -- Plugin configuration + tools = { + }, + -- LSP configuration + server = { + default_settings = { + -- rust-analyzer language server configuration + -- https://rust-analyzer.github.io/book/configuration.html + ['rust-analyzer'] = { + checkOnSave = true, + check = { + enable = true, + command = "clippy", + features = "all", + }, + completion = { + autoimport = { + enable = false; + } + }, + files = { + exclude = { + "build-dir/", + ".flatpak-builder", + } + } + --settings = { + -- cargo = { allFeatures = true }, + -- imports = { group = { enable = false } }, + -- completion = { postfix = { enable = false } }, + -- -- https://www.reddit.com/r/rust/comments/1e978l7/comment/led7ibp/ + -- -- checkOnSave = { command = "clippy" }, + -- checkOnSave = { command = false }, + + -- diagnostics = { enable = true }, + -- rustfmt = { enable = true }, + --} + }, + }, + }, + -- DAP configuration + dap = { + }, +} -- cgit