From 1302056eddd9a69ea2d0ffdf8bedd8582fb5a907 Mon Sep 17 00:00:00 2001 From: cryxtalix Date: Fri, 8 May 2026 03:43:16 +0800 Subject: Update --- .config/nvim/.luarc.json | 5 - .config/nvim/ftplugin/cpp.lua | 12 ++ .config/nvim/ftplugin/html.lua | 12 ++ .config/nvim/ftplugin/htmldjango.lua | 12 ++ .config/nvim/ftplugin/toml.lua | 12 ++ .config/nvim/init.lua | 132 +--------------------- .config/nvim/init.lua.save | 31 ----- .config/nvim/lazy-lock.json | 40 +++---- .config/nvim/lua/configs/basic.lua | 84 ++++++++++++++ .config/nvim/lua/configs/filetype.lua | 7 ++ .config/nvim/lua/configs/lazyvim.lua | 40 +++++++ .config/nvim/lua/plugins/lsp.lua | 5 +- .config/nvim_pack/ftplugin/c.lua | 12 ++ .config/nvim_pack/ftplugin/json.lua | 12 ++ .config/nvim_pack/ftplugin/lua.lua | 14 +++ .config/nvim_pack/ftplugin/make.lua | 12 ++ .config/nvim_pack/ftplugin/python.lua | 12 ++ .config/nvim_pack/ftplugin/rust.lua | 31 +++++ .config/nvim_pack/ftplugin/sh.lua | 12 ++ .config/nvim_pack/ftplugin/xml.lua | 12 ++ .config/nvim_pack/init.lua | 10 ++ .config/nvim_pack/lsp/bashls.lua | 0 .config/nvim_pack/lsp/clangd.lua | 0 .config/nvim_pack/lsp/lemminx.lua | 0 .config/nvim_pack/lsp/lua_ls.lua | 19 ++++ .config/nvim_pack/lsp/marksman.lua | 0 .config/nvim_pack/lsp/pyright.lua | 16 +++ .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 +++++++++ .config/nvim_pack/nvim-pack-lock.json | 40 +++++++ 35 files changed, 628 insertions(+), 187 deletions(-) delete mode 100644 .config/nvim/.luarc.json create mode 100644 .config/nvim/ftplugin/cpp.lua create mode 100644 .config/nvim/ftplugin/html.lua create mode 100644 .config/nvim/ftplugin/htmldjango.lua create mode 100644 .config/nvim/ftplugin/toml.lua delete mode 100644 .config/nvim/init.lua.save create mode 100644 .config/nvim/lua/configs/basic.lua create mode 100644 .config/nvim/lua/configs/filetype.lua create mode 100644 .config/nvim/lua/configs/lazyvim.lua create mode 100644 .config/nvim_pack/ftplugin/c.lua create mode 100644 .config/nvim_pack/ftplugin/json.lua create mode 100644 .config/nvim_pack/ftplugin/lua.lua create mode 100644 .config/nvim_pack/ftplugin/make.lua create mode 100644 .config/nvim_pack/ftplugin/python.lua create mode 100644 .config/nvim_pack/ftplugin/rust.lua create mode 100644 .config/nvim_pack/ftplugin/sh.lua create mode 100644 .config/nvim_pack/ftplugin/xml.lua create mode 100644 .config/nvim_pack/init.lua create mode 100644 .config/nvim_pack/lsp/bashls.lua create mode 100644 .config/nvim_pack/lsp/clangd.lua create mode 100644 .config/nvim_pack/lsp/lemminx.lua create mode 100644 .config/nvim_pack/lsp/lua_ls.lua create mode 100644 .config/nvim_pack/lsp/marksman.lua create mode 100644 .config/nvim_pack/lsp/pyright.lua 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 create mode 100644 .config/nvim_pack/nvim-pack-lock.json (limited to '.config') diff --git a/.config/nvim/.luarc.json b/.config/nvim/.luarc.json deleted file mode 100644 index 1e1765c..0000000 --- a/.config/nvim/.luarc.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "diagnostics.globals": [ - "vim" - ] -} \ No newline at end of file diff --git a/.config/nvim/ftplugin/cpp.lua b/.config/nvim/ftplugin/cpp.lua new file mode 100644 index 0000000..4514ab3 --- /dev/null +++ b/.config/nvim/ftplugin/cpp.lua @@ -0,0 +1,12 @@ +local indent_size = 8 +local use_tabs = false + +local settings = string.format("setlocal softtabstop=%s tabstop=%s shiftwidth=%s", indent_size, indent_size, indent_size) + +if use_tabs == true then + settings = settings .. " noexpandtab" +else + settings = settings .. " expandtab" +end + +vim.cmd(settings) diff --git a/.config/nvim/ftplugin/html.lua b/.config/nvim/ftplugin/html.lua new file mode 100644 index 0000000..3fbcec4 --- /dev/null +++ b/.config/nvim/ftplugin/html.lua @@ -0,0 +1,12 @@ +local indent_size = 4 +local use_tabs = false + +local settings = string.format("setlocal softtabstop=%s tabstop=%s shiftwidth=%s", indent_size, indent_size, indent_size) + +if use_tabs == true then + settings = settings .. " noexpandtab" +else + settings = settings .. " expandtab" +end + +vim.cmd(settings) diff --git a/.config/nvim/ftplugin/htmldjango.lua b/.config/nvim/ftplugin/htmldjango.lua new file mode 100644 index 0000000..3fbcec4 --- /dev/null +++ b/.config/nvim/ftplugin/htmldjango.lua @@ -0,0 +1,12 @@ +local indent_size = 4 +local use_tabs = false + +local settings = string.format("setlocal softtabstop=%s tabstop=%s shiftwidth=%s", indent_size, indent_size, indent_size) + +if use_tabs == true then + settings = settings .. " noexpandtab" +else + settings = settings .. " expandtab" +end + +vim.cmd(settings) diff --git a/.config/nvim/ftplugin/toml.lua b/.config/nvim/ftplugin/toml.lua new file mode 100644 index 0000000..3fbcec4 --- /dev/null +++ b/.config/nvim/ftplugin/toml.lua @@ -0,0 +1,12 @@ +local indent_size = 4 +local use_tabs = false + +local settings = string.format("setlocal softtabstop=%s tabstop=%s shiftwidth=%s", indent_size, indent_size, indent_size) + +if use_tabs == true then + settings = settings .. " noexpandtab" +else + settings = settings .. " expandtab" +end + +vim.cmd(settings) diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 5fe9ee8..90379f8 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -1,128 +1,4 @@ ------------ --- 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, -}) - --------------- --- Lazy.vim -- --------------- -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) - --- Rename Tmux Window to File Opened by Neovim --- https://github.com/Dyslectric/neovim-tmux-window-rename -if vim.env.TMUX ~= nil then - -- Define an autocommand for BufEnter and FocusGained events - vim.api.nvim_create_autocmd({"BufEnter", "FocusGained"}, { - pattern = "*", - callback = function() - local file_name = vim.fn.expand("%:t") - local folder_name = vim.fn.expand("%:p:h:t") - local tmux_command = string.format( - "tmux rename-window 'Nv:%s/%s'", folder_name, file_name - ) - vim.fn.system(tmux_command) - end - }) - - -- Define an autocommand for the VimLeave event - vim.api.nvim_create_autocmd("VimLeave", { - pattern = "*", - callback = function() - local shell = vim.env.SHELL or "sh" - vim.fn.system("tmux set-window-option automatic-rename on") - end - }) -end - -require("lazy").setup("plugins") +--- General configs -- +require("configs.basic") +require("configs.filetype") +require("configs.lazyvim") diff --git a/.config/nvim/init.lua.save b/.config/nvim/init.lua.save deleted file mode 100644 index 8abcdc8..0000000 --- a/.config/nvim/init.lua.save +++ /dev/null @@ -1,31 +0,0 @@ --- Basic -vim.g.mapleader = " " -vim.opt.wrap = true -vim.opt.number = true -vim.opt.relativenumber = true -vim.opt.laststatus = 2 -vim.opt.hlsearch = true -vim.opt.incsearch = true -vim.opt.syntax = ON -vim.cmd("filetype plugin on") - --- Temp -vim.opt.mouse = "" - --- Install Lazy.vim -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) - -local opts = {} - -require("lazy").setup("plugins") diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 443fc76..f8d3a95 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,25 +1,25 @@ { - "LuaSnip": { "branch": "master", "commit": "c9b9a22904c97d0eb69ccb9bab76037838326817" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "99290b3ec1322070bcfb9e846450a46f6efa50f0" }, + "LuaSnip": { "branch": "master", "commit": "3732756842a2f7e0e76a7b0487e9692072857277" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" }, "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, - "friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" }, - "lazy.nvim": { "branch": "main", "commit": "85c7ff3711b730b4030d03144f6db6375044ae82" }, - "markdown-toc": { "branch": "main", "commit": "1454bf3b4bcb855f7df41c59dfae08cc824141a0" }, + "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, + "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, + "markdown-toc": { "branch": "main", "commit": "1aa53cec6207754610fc0254662cdfff730aceab" }, "marks.nvim": { "branch": "master", "commit": "f353e8c08c50f39e99a9ed474172df7eddd89b72" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "e942edf5c85b6a2ab74059ea566cac5b3e1514a4" }, - "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, - "mini.nvim": { "branch": "main", "commit": "44a3ab2bc6b40edeb7a76359826c9779d5c70cb5" }, - "none-ls.nvim": { "branch": "main", "commit": "af318216b744f2fe2d5afa6febb01f455ae61d6c" }, - "nvim-cmp": { "branch": "main", "commit": "8c82d0bd31299dbff7f8e780f5e06d2283de9678" }, - "nvim-dap": { "branch": "master", "commit": "99807078c5089ed30e0547aa4b52c5867933f426" }, - "nvim-dap-ui": { "branch": "master", "commit": "727c032a8f63899baccb42a1c26f27687e62fc5e" }, - "nvim-dap-virtual-text": { "branch": "master", "commit": "df66808cd78b5a97576bbaeee95ed5ca385a9750" }, - "nvim-lspconfig": { "branch": "master", "commit": "339ccc81e08793c3af9b83882a6ebd90c9cc0d3b" }, - "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, - "nvim-treesitter": { "branch": "master", "commit": "5da195ac3dfafd08d8b10756d975f0e01e1d563a" }, - "plenary.nvim": { "branch": "master", "commit": "3707cdb1e43f5cea73afb6037e6494e7ce847a66" }, - "render-markdown.nvim": { "branch": "main", "commit": "ad055861d17afe058bd835e82292e14a64b51b1d" }, - "rustaceanvim": { "branch": "master", "commit": "66398662c07d265b226897500ed50eafba3dffb4" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "fe661093f4b05136437b531e7f959af2a2ae66c8" }, + "mason.nvim": { "branch": "main", "commit": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65" }, + "mini.nvim": { "branch": "main", "commit": "8dccba88fc4dce006ca0ad668067c9e0d5ce7702" }, + "none-ls.nvim": { "branch": "main", "commit": "1fcf9cbf9acf893455c6cee792537aa709de62cb" }, + "nvim-cmp": { "branch": "main", "commit": "85bbfad83f804f11688d1ab9486b459e699292d6" }, + "nvim-dap": { "branch": "master", "commit": "cdfd55a133f63228c55f91378f12908cb2a78ded" }, + "nvim-dap-ui": { "branch": "master", "commit": "cf91d5e2d07c72903d052f5207511bf7ecdb7122" }, + "nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" }, + "nvim-lspconfig": { "branch": "master", "commit": "92ee7d42320edfbb81f3cad851314ab197fa324a" }, + "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, + "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, + "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, + "render-markdown.nvim": { "branch": "main", "commit": "ae89236e2389836cf1c3787b2b80d5d8685cc13f" }, + "rustaceanvim": { "branch": "master", "commit": "88575b98bb9937fb9983ddec5e532b67e75ce677" }, "telescope-dap.nvim": { "branch": "master", "commit": "783366bd6c1e7fa0a5c59c07db37f49c805a28df" }, - "telescope.nvim": { "branch": "master", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" } + "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" } } diff --git a/.config/nvim/lua/configs/basic.lua b/.config/nvim/lua/configs/basic.lua new file mode 100644 index 0000000..f4ccce1 --- /dev/null +++ b/.config/nvim/lua/configs/basic.lua @@ -0,0 +1,84 @@ +----------- +-- 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/lua/configs/filetype.lua b/.config/nvim/lua/configs/filetype.lua new file mode 100644 index 0000000..82725e2 --- /dev/null +++ b/.config/nvim/lua/configs/filetype.lua @@ -0,0 +1,7 @@ +vim.filetype.add({ + extension = { + mq4 = "c", + mq5 = "cpp", + mqh = "cpp", + } +}) diff --git a/.config/nvim/lua/configs/lazyvim.lua b/.config/nvim/lua/configs/lazyvim.lua new file mode 100644 index 0000000..0b643b4 --- /dev/null +++ b/.config/nvim/lua/configs/lazyvim.lua @@ -0,0 +1,40 @@ +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) + +-- Rename Tmux Window to File Opened by Neovim +-- https://github.com/Dyslectric/neovim-tmux-window-rename +if vim.env.TMUX ~= nil then + -- Define an autocommand for BufEnter and FocusGained events + vim.api.nvim_create_autocmd({"BufEnter", "FocusGained"}, { + pattern = "*", + callback = function() + local file_name = vim.fn.expand("%:t") + local folder_name = vim.fn.expand("%:p:h:t") + local tmux_command = string.format( + "tmux rename-window 'Nv:%s/%s'", folder_name, file_name + ) + vim.fn.system(tmux_command) + end + }) + + -- Define an autocommand for the VimLeave event + vim.api.nvim_create_autocmd("VimLeave", { + pattern = "*", + callback = function() + local shell = vim.env.SHELL or "sh" + vim.fn.system("tmux set-window-option automatic-rename on") + end + }) +end + +require("lazy").setup("plugins") diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua index 296e73a..0314c42 100644 --- a/.config/nvim/lua/plugins/lsp.lua +++ b/.config/nvim/lua/plugins/lsp.lua @@ -30,11 +30,10 @@ return { config = function() -- Advertise autocompletion to lsp local capabilities = require('cmp_nvim_lsp').default_capabilities() - local lspconfig = require("lspconfig") for _, server in ipairs(servers) do - lspconfig[server].setup { + vim.lsp.config(server, { capabilities = capabilities, - } + }) end -- Key mapping diff --git a/.config/nvim_pack/ftplugin/c.lua b/.config/nvim_pack/ftplugin/c.lua new file mode 100644 index 0000000..4514ab3 --- /dev/null +++ b/.config/nvim_pack/ftplugin/c.lua @@ -0,0 +1,12 @@ +local indent_size = 8 +local use_tabs = false + +local settings = string.format("setlocal softtabstop=%s tabstop=%s shiftwidth=%s", indent_size, indent_size, indent_size) + +if use_tabs == true then + settings = settings .. " noexpandtab" +else + settings = settings .. " expandtab" +end + +vim.cmd(settings) diff --git a/.config/nvim_pack/ftplugin/json.lua b/.config/nvim_pack/ftplugin/json.lua new file mode 100644 index 0000000..3fbcec4 --- /dev/null +++ b/.config/nvim_pack/ftplugin/json.lua @@ -0,0 +1,12 @@ +local indent_size = 4 +local use_tabs = false + +local settings = string.format("setlocal softtabstop=%s tabstop=%s shiftwidth=%s", indent_size, indent_size, indent_size) + +if use_tabs == true then + settings = settings .. " noexpandtab" +else + settings = settings .. " expandtab" +end + +vim.cmd(settings) diff --git a/.config/nvim_pack/ftplugin/lua.lua b/.config/nvim_pack/ftplugin/lua.lua new file mode 100644 index 0000000..275b1a9 --- /dev/null +++ b/.config/nvim_pack/ftplugin/lua.lua @@ -0,0 +1,14 @@ +local indent_size = 2 +local use_tabs = false + +local settings = string.format("setlocal softtabstop=%s tabstop=%s shiftwidth=%s", indent_size, indent_size, indent_size) + +if use_tabs == true then + settings = settings .. " noexpandtab" +else + settings = settings .. " expandtab" +end + +vim.cmd(settings) + +-- Check http://vimcasts.org/episodes/tabs-and-spaces/ for more info on tabs and spaces diff --git a/.config/nvim_pack/ftplugin/make.lua b/.config/nvim_pack/ftplugin/make.lua new file mode 100644 index 0000000..2ad7f95 --- /dev/null +++ b/.config/nvim_pack/ftplugin/make.lua @@ -0,0 +1,12 @@ +local indent_size = 8 +local use_tabs = true + +local settings = string.format("setlocal softtabstop=%s tabstop=%s shiftwidth=%s", indent_size, indent_size, indent_size) + +if use_tabs == true then + settings = settings .. " noexpandtab" +else + settings = settings .. " expandtab" +end + +vim.cmd(settings) diff --git a/.config/nvim_pack/ftplugin/python.lua b/.config/nvim_pack/ftplugin/python.lua new file mode 100644 index 0000000..3fbcec4 --- /dev/null +++ b/.config/nvim_pack/ftplugin/python.lua @@ -0,0 +1,12 @@ +local indent_size = 4 +local use_tabs = false + +local settings = string.format("setlocal softtabstop=%s tabstop=%s shiftwidth=%s", indent_size, indent_size, indent_size) + +if use_tabs == true then + settings = settings .. " noexpandtab" +else + settings = settings .. " expandtab" +end + +vim.cmd(settings) diff --git a/.config/nvim_pack/ftplugin/rust.lua b/.config/nvim_pack/ftplugin/rust.lua new file mode 100644 index 0000000..029f0da --- /dev/null +++ b/.config/nvim_pack/ftplugin/rust.lua @@ -0,0 +1,31 @@ +local indent_size = 4 +local use_tabs = false + +local settings = string.format("setlocal softtabstop=%s tabstop=%s shiftwidth=%s", indent_size, indent_size, indent_size) + +if use_tabs == true then + settings = settings .. " noexpandtab" +else + settings = settings .. " expandtab" +end + +local bufnr = vim.api.nvim_get_current_buf() +vim.keymap.set( + "n", + "a", + function() + vim.cmd.RustLsp('codeAction') -- supports rust-analyzer's grouping + -- or vim.lsp.buf.codeAction() if you don't want grouping. + end, + { silent = true, buffer = bufnr } +) +vim.keymap.set( + "n", + "K", -- Override Neovim's built-in hover keymap with rustaceanvim's hover actions + function() + vim.cmd.RustLsp({'hover', 'actions'}) + end, + { silent = true, buffer = bufnr } +) + +vim.cmd(settings) diff --git a/.config/nvim_pack/ftplugin/sh.lua b/.config/nvim_pack/ftplugin/sh.lua new file mode 100644 index 0000000..4d8e3f2 --- /dev/null +++ b/.config/nvim_pack/ftplugin/sh.lua @@ -0,0 +1,12 @@ +local indent_size = 2 +local use_tabs = false + +local settings = string.format("setlocal softtabstop=%s tabstop=%s shiftwidth=%s", indent_size, indent_size, indent_size) + +if use_tabs == true then + settings = settings .. " noexpandtab" +else + settings = settings .. " expandtab" +end + +vim.cmd(settings) diff --git a/.config/nvim_pack/ftplugin/xml.lua b/.config/nvim_pack/ftplugin/xml.lua new file mode 100644 index 0000000..4d8e3f2 --- /dev/null +++ b/.config/nvim_pack/ftplugin/xml.lua @@ -0,0 +1,12 @@ +local indent_size = 2 +local use_tabs = false + +local settings = string.format("setlocal softtabstop=%s tabstop=%s shiftwidth=%s", indent_size, indent_size, indent_size) + +if use_tabs == true then + settings = settings .. " noexpandtab" +else + settings = settings .. " expandtab" +end + +vim.cmd(settings) diff --git a/.config/nvim_pack/init.lua b/.config/nvim_pack/init.lua new file mode 100644 index 0000000..bfc4b5b --- /dev/null +++ b/.config/nvim_pack/init.lua @@ -0,0 +1,10 @@ +-- General configs -- +require("configs.basic") +require("configs.vim-plug") +require("configs.lsp") + +-- Install plugins with native vim.pack -- +require("plugins.mason") +require("plugins.marks") +require("plugins.render-markdown") +require("plugins.rustaceanvim") diff --git a/.config/nvim_pack/lsp/bashls.lua b/.config/nvim_pack/lsp/bashls.lua new file mode 100644 index 0000000..e69de29 diff --git a/.config/nvim_pack/lsp/clangd.lua b/.config/nvim_pack/lsp/clangd.lua new file mode 100644 index 0000000..e69de29 diff --git a/.config/nvim_pack/lsp/lemminx.lua b/.config/nvim_pack/lsp/lemminx.lua new file mode 100644 index 0000000..e69de29 diff --git a/.config/nvim_pack/lsp/lua_ls.lua b/.config/nvim_pack/lsp/lua_ls.lua new file mode 100644 index 0000000..c0a6d56 --- /dev/null +++ b/.config/nvim_pack/lsp/lua_ls.lua @@ -0,0 +1,19 @@ +return { + -- Command and arguments to start the server. + cmd = { 'lua-language-server' }, + -- Filetypes to automatically attach to. + filetypes = { 'lua' }, + -- Sets the "workspace" to the directory where any of these files is found. + -- Files that share a root directory will reuse the LSP server connection. + -- Nested lists indicate equal priority, see |vim.lsp.Config|. + root_markers = { { '.luarc.json', '.luarc.jsonc' }, '.git' }, + -- Specific settings to send to the server. The schema is server-defined. + -- Example: https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json + settings = { + Lua = { + runtime = { + version = 'LuaJIT', + } + } + } +} diff --git a/.config/nvim_pack/lsp/marksman.lua b/.config/nvim_pack/lsp/marksman.lua new file mode 100644 index 0000000..e69de29 diff --git a/.config/nvim_pack/lsp/pyright.lua b/.config/nvim_pack/lsp/pyright.lua new file mode 100644 index 0000000..aece9a7 --- /dev/null +++ b/.config/nvim_pack/lsp/pyright.lua @@ -0,0 +1,16 @@ +return { + cmd = { "pyright-langserver", "--stdio" }, + filetypes = { "python" }, + root_dir = function(filename) + return util.root_pattern(unpack(root_files))(filename) or util.path.dirname(filename) + end, + settings = { + python = { + analysis = { + autoSearchPaths = true, + diagnosticMode = "workspace", + useLibraryCodeForTypes = true + } + } + } +} 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 = { + }, +} diff --git a/.config/nvim_pack/nvim-pack-lock.json b/.config/nvim_pack/nvim-pack-lock.json new file mode 100644 index 0000000..f9b72cb --- /dev/null +++ b/.config/nvim_pack/nvim-pack-lock.json @@ -0,0 +1,40 @@ +{ + "plugins": { + "marks": { + "rev": "f353e8c08c50f39e99a9ed474172df7eddd89b72", + "src": "https://github.com/chentoast/marks.nvim.git" + }, + "marks.nvim": { + "rev": "f353e8c08c50f39e99a9ed474172df7eddd89b72", + "src": "https://github.com/chentoast/marks.nvim.git", + "version": "'main'" + }, + "mason-lspconfig.nvim": { + "rev": "4cfe411526a7a99c18281135e8b4765ae6330d15", + "src": "https://github.com/mason-org/mason-lspconfig.nvim.git", + "version": "'main'" + }, + "mason.nvim": { + "rev": "57e5a8addb8c71fb063ee4acda466c7cf6ad2800", + "src": "https://github.com/mason-org/mason.nvim.git", + "version": "'main'" + }, + "mini.nvim": { + "rev": "43ec25063430196d36f5fff5758c9101775f3d57", + "src": "https://github.com/nvim-mini/mini.nvim" + }, + "nvim-treesitter": { + "rev": "c6dd314086f7b471bf6c9110092a94ce1c06d220", + "src": "https://github.com/nvim-treesitter/nvim-treesitter" + }, + "render-markdown.nvim": { + "rev": "07d088bf8bdadd159eb807b90eaee86a4778383f", + "src": "https://github.com/MeanderingProgrammer/render-markdown.nvim" + }, + "rustaceanvim": { + "rev": "f8bf440870c138bf45bc82c42f55d280569964b8", + "src": "https://github.com/mrcjkb/rustaceanvim.git", + "version": "'master'" + } + } +} \ No newline at end of file -- cgit