From 27ceebaa91380d024e3fd7b4d3e24ef373e56010 Mon Sep 17 00:00:00 2001 From: Dmitry Voronin Date: Sat, 24 Feb 2024 22:00:47 +0300 Subject: [PATCH] Nvim : Move config to nix. --- .config/linux/system/flake.nix | 1 + .config/linux/system/module/common/Nvim.nix | 55 +++++++++++++++++ .../linux/system/module/common/Package.nix | 3 +- .../linux/system/module/common/Wallpaper.nix | 4 +- .../module/common/nvim/config/Autoread.lua | 5 ++ .../system/module/common/nvim/config/Etc.lua | 27 +++++++++ .../module/common/nvim/config/Search.lua | 5 ++ .../system/module/common/nvim/config/Tab.lua | 9 +++ .../module/common/nvim/key/Autocomplete.lua | 5 ++ .../system/module/common/nvim/key/Buffer.lua | 12 ++++ .../system/module/common/nvim/key/Comment.lua | 5 ++ .../system/module/common/nvim/key/Common.lua | 22 +++++++ .../module/common/nvim/key/Filetree.lua | 2 + .../system/module/common/nvim/key/Fold.lua | 5 ++ .../module/common/nvim/key/Gitsigns.lua | 2 + .../system/module/common/nvim}/key/Leader.lua | 2 - .../system/module/common/nvim/key/Lsp.lua | 0 .../module/common/nvim/key/Navigation.lua | 23 +++++++ .../system/module/common/nvim/key/Rekey.lua | 49 +++++++++++++++ .../system/module/common/nvim/key/Sort.lua | 2 + .../module/common/nvim/key/Telescope.lua | 6 ++ .../module/common/nvim/key/Terminal.lua | 5 ++ .../system/module/common/nvim/key/Todo.lua | 2 + .../system/module/common/nvim/key/Trouble.lua | 2 + .../system/module/common/nvim/key/Update.lua | 5 ++ .../module/common/nvim/key/Whichkey.lua | 2 + .../module/common/nvim/plugin/Align.lua | 7 +++ .../module/common/nvim/plugin/Autoclose.lua | 13 ++++ .../module/common/nvim/plugin/Bufferline.lua | 1 + .../common/nvim/plugin/Closebuffers.lua | 7 +++ .../module/common/nvim/plugin/Filetree.lua | 36 +++++++++++ .../system/module/common/nvim/plugin/Fold.lua | 3 + .../module/common/nvim/plugin/Gitsigns.lua | 43 +++++++++++++ .../module/common/nvim/plugin/Gruvbox.lua | 1 + .../module/common/nvim/plugin/Indent.lua | 6 ++ .../system/module/common/nvim/plugin/Init.lua | 49 +++++++++++++++ .../module/common/nvim/plugin/Lualine.lua | 40 +++++++++++++ .../module/common/nvim/plugin/Telescope.lua | 11 ++++ .../system/module/common/nvim/plugin/Todo.lua | 53 ++++++++++++++++ .../module/common/nvim/plugin/Tokyonight.lua | 23 +++++++ .../module/common/nvim/plugin/Treesitter.lua | 19 ++++++ .../module/common/nvim/plugin/Trouble.lua | 1 + .../module/common/nvim/plugin/lsp/Kotlin.lua | 3 + .../module/common/nvim/plugin/lsp/Python.lua | 3 + .../module/common/nvim/plugin/lsp/Rust.lua | 16 +++++ .../module/common/nvim/plugin/lsp/Tex.lua | 60 +++++++++++++++++++ 46 files changed, 648 insertions(+), 7 deletions(-) create mode 100644 .config/linux/system/module/common/Nvim.nix create mode 100644 .config/linux/system/module/common/nvim/config/Autoread.lua create mode 100644 .config/linux/system/module/common/nvim/config/Etc.lua create mode 100644 .config/linux/system/module/common/nvim/config/Search.lua create mode 100644 .config/linux/system/module/common/nvim/config/Tab.lua create mode 100644 .config/linux/system/module/common/nvim/key/Autocomplete.lua create mode 100644 .config/linux/system/module/common/nvim/key/Buffer.lua create mode 100644 .config/linux/system/module/common/nvim/key/Comment.lua create mode 100644 .config/linux/system/module/common/nvim/key/Common.lua create mode 100644 .config/linux/system/module/common/nvim/key/Filetree.lua create mode 100644 .config/linux/system/module/common/nvim/key/Fold.lua create mode 100644 .config/linux/system/module/common/nvim/key/Gitsigns.lua rename .config/{nvim/lua => linux/system/module/common/nvim}/key/Leader.lua (86%) create mode 100644 .config/linux/system/module/common/nvim/key/Lsp.lua create mode 100644 .config/linux/system/module/common/nvim/key/Navigation.lua create mode 100644 .config/linux/system/module/common/nvim/key/Rekey.lua create mode 100644 .config/linux/system/module/common/nvim/key/Sort.lua create mode 100644 .config/linux/system/module/common/nvim/key/Telescope.lua create mode 100644 .config/linux/system/module/common/nvim/key/Terminal.lua create mode 100644 .config/linux/system/module/common/nvim/key/Todo.lua create mode 100644 .config/linux/system/module/common/nvim/key/Trouble.lua create mode 100644 .config/linux/system/module/common/nvim/key/Update.lua create mode 100644 .config/linux/system/module/common/nvim/key/Whichkey.lua create mode 100644 .config/linux/system/module/common/nvim/plugin/Align.lua create mode 100644 .config/linux/system/module/common/nvim/plugin/Autoclose.lua create mode 100644 .config/linux/system/module/common/nvim/plugin/Bufferline.lua create mode 100644 .config/linux/system/module/common/nvim/plugin/Closebuffers.lua create mode 100644 .config/linux/system/module/common/nvim/plugin/Filetree.lua create mode 100644 .config/linux/system/module/common/nvim/plugin/Fold.lua create mode 100644 .config/linux/system/module/common/nvim/plugin/Gitsigns.lua create mode 100644 .config/linux/system/module/common/nvim/plugin/Gruvbox.lua create mode 100644 .config/linux/system/module/common/nvim/plugin/Indent.lua create mode 100644 .config/linux/system/module/common/nvim/plugin/Init.lua create mode 100644 .config/linux/system/module/common/nvim/plugin/Lualine.lua create mode 100644 .config/linux/system/module/common/nvim/plugin/Telescope.lua create mode 100644 .config/linux/system/module/common/nvim/plugin/Todo.lua create mode 100644 .config/linux/system/module/common/nvim/plugin/Tokyonight.lua create mode 100644 .config/linux/system/module/common/nvim/plugin/Treesitter.lua create mode 100644 .config/linux/system/module/common/nvim/plugin/Trouble.lua create mode 100644 .config/linux/system/module/common/nvim/plugin/lsp/Kotlin.lua create mode 100644 .config/linux/system/module/common/nvim/plugin/lsp/Python.lua create mode 100644 .config/linux/system/module/common/nvim/plugin/lsp/Rust.lua create mode 100644 .config/linux/system/module/common/nvim/plugin/lsp/Tex.lua diff --git a/.config/linux/system/flake.nix b/.config/linux/system/flake.nix index 6f959f7..f0b567a 100644 --- a/.config/linux/system/flake.nix +++ b/.config/linux/system/flake.nix @@ -28,6 +28,7 @@ ./module/common/Locale.nix ./module/common/Network.nix ./module/common/Nix.nix + ./module/common/Nvim.nix ./module/common/Package.nix ./module/common/Root.nix ./module/common/Sshd.nix diff --git a/.config/linux/system/module/common/Nvim.nix b/.config/linux/system/module/common/Nvim.nix new file mode 100644 index 0000000..472ccd0 --- /dev/null +++ b/.config/linux/system/module/common/Nvim.nix @@ -0,0 +1,55 @@ +{ environment, ... }: let + nvimSrc = "/etc/nvim/"; +in { + environment.etc.nvim.source = ./nvim; + + programs.neovim = { + enable = true; + viAlias = true; + vimAlias = true; + configure = { + customRC = '' + lua dofile("${nvimSrc}/plugin/Init.lua") + lua dofile("${nvimSrc}/plugin/Filetree.lua") + lua dofile("${nvimSrc}/plugin/lsp/Rust.lua") + lua dofile("${nvimSrc}/plugin/lsp/Tex.lua") + lua dofile("${nvimSrc}/plugin/Bufferline.lua") + lua dofile("${nvimSrc}/plugin/Lualine.lua") + lua dofile("${nvimSrc}/plugin/Autoclose.lua") + lua dofile("${nvimSrc}/plugin/Gitsigns.lua") + lua dofile("${nvimSrc}/plugin/Trouble.lua") + lua dofile("${nvimSrc}/plugin/Tokyonight.lua") + lua dofile("${nvimSrc}/plugin/Gruvbox.lua") + lua dofile("${nvimSrc}/plugin/Closebuffers.lua") + lua dofile("${nvimSrc}/plugin/Telescope.lua") + lua dofile("${nvimSrc}/plugin/Todo.lua") + lua dofile("${nvimSrc}/plugin/Indent.lua") + lua dofile("${nvimSrc}/plugin/Align.lua") + lua dofile("${nvimSrc}/plugin/Treesitter.lua") + lua dofile("${nvimSrc}/plugin/Fold.lua") + lua dofile("${nvimSrc}/config/Autoread.lua") + lua dofile("${nvimSrc}/config/Etc.lua") + lua dofile("${nvimSrc}/config/Search.lua") + lua dofile("${nvimSrc}/config/Tab.lua") + lua dofile("${nvimSrc}/key/Rekey.lua") + lua dofile("${nvimSrc}/key/Leader.lua") + lua dofile("${nvimSrc}/key/Autocomplete.lua") + lua dofile("${nvimSrc}/key/Buffer.lua") + lua dofile("${nvimSrc}/key/Comment.lua") + lua dofile("${nvimSrc}/key/Common.lua") + lua dofile("${nvimSrc}/key/Filetree.lua") + lua dofile("${nvimSrc}/key/Fold.lua") + lua dofile("${nvimSrc}/key/Gitsigns.lua") + lua dofile("${nvimSrc}/key/Lsp.lua") + lua dofile("${nvimSrc}/key/Navigation.lua") + lua dofile("${nvimSrc}/key/Sort.lua") + lua dofile("${nvimSrc}/key/Telescope.lua") + lua dofile("${nvimSrc}/key/Terminal.lua") + lua dofile("${nvimSrc}/key/Todo.lua") + lua dofile("${nvimSrc}/key/Trouble.lua") + lua dofile("${nvimSrc}/key/Update.lua") + lua dofile("${nvimSrc}/key/Whichkey.lua") + ''; + }; + }; +} diff --git a/.config/linux/system/module/common/Package.nix b/.config/linux/system/module/common/Package.nix index 3118d93..1563edf 100644 --- a/.config/linux/system/module/common/Package.nix +++ b/.config/linux/system/module/common/Package.nix @@ -39,6 +39,5 @@ ]; # Special packages. - programs.adb.enable = true; - programs.neovim.enable = true; + programs.adb.enable = true; } diff --git a/.config/linux/system/module/common/Wallpaper.nix b/.config/linux/system/module/common/Wallpaper.nix index b69338a..7ebfc0c 100644 --- a/.config/linux/system/module/common/Wallpaper.nix +++ b/.config/linux/system/module/common/Wallpaper.nix @@ -1,5 +1,3 @@ { environment, ... }: { - environment.etc.wallpaper = { - source = ../../../wallpaper; # TODO: Use a path relative to repo. - }; + environment.etc.wallpaper.source = ../../../wallpaper; # TODO: Use a path relative to repo. } diff --git a/.config/linux/system/module/common/nvim/config/Autoread.lua b/.config/linux/system/module/common/nvim/config/Autoread.lua new file mode 100644 index 0000000..bc9a40c --- /dev/null +++ b/.config/linux/system/module/common/nvim/config/Autoread.lua @@ -0,0 +1,5 @@ +vim.o.autoread = true +vim.api.nvim_create_autocmd({ "BufEnter", "CursorHold", "CursorHoldI", "FocusGained" }, { + command = "if mode() != 'c' | checktime | endif", + pattern = { "*" }, +}) diff --git a/.config/linux/system/module/common/nvim/config/Etc.lua b/.config/linux/system/module/common/nvim/config/Etc.lua new file mode 100644 index 0000000..9d6ae87 --- /dev/null +++ b/.config/linux/system/module/common/nvim/config/Etc.lua @@ -0,0 +1,27 @@ +-- TODO: Add comments and separate files. +vim.opt.clipboard = "unnamedplus" +-- vim.opt.completeopt = "menuone,noselect" +vim.opt.cursorline = true +vim.opt.fixeol = false +vim.opt.number = true +vim.opt.splitbelow = true +vim.opt.splitright = true +vim.opt.termguicolors = true +vim.opt.ttyfast = true +vim.opt.wildmode = "longest,list" + +-- Disable continuing comments on newline. +vim.cmd("autocmd BufEnter * set fo-=c fo-=r fo-=o") + +-- Disable mouse. +vim.cmd("set mouse=") + +-- Disable signs for diagnostics. +vim.diagnostic.config({ signs = false }) + +-- Display invisible characters. +-- vim.cmd("set list listchars=tab:>\\ ,trail:-,eol:,lead:.") +vim.cmd("set list listchars=tab:>\\ ,trail:-,lead:.") + +-- Relative line numbers. +vim.wo.relativenumber = true diff --git a/.config/linux/system/module/common/nvim/config/Search.lua b/.config/linux/system/module/common/nvim/config/Search.lua new file mode 100644 index 0000000..08e709e --- /dev/null +++ b/.config/linux/system/module/common/nvim/config/Search.lua @@ -0,0 +1,5 @@ +vim.opt.hlsearch = true +vim.opt.ignorecase = true +vim.opt.incsearch = true +vim.opt.showmatch = true +vim.opt.smartcase = true diff --git a/.config/linux/system/module/common/nvim/config/Tab.lua b/.config/linux/system/module/common/nvim/config/Tab.lua new file mode 100644 index 0000000..ef4af91 --- /dev/null +++ b/.config/linux/system/module/common/nvim/config/Tab.lua @@ -0,0 +1,9 @@ +vim.opt.autoindent = true +vim.opt.expandtab = false +vim.opt.shiftwidth = 2 +-- vim.opt.smartindent = true +vim.opt.softtabstop = 2 +vim.opt.tabstop = 2 + +-- Disable Markdown forced formatting. +vim.g.markdown_recommended_style = 0 diff --git a/.config/linux/system/module/common/nvim/key/Autocomplete.lua b/.config/linux/system/module/common/nvim/key/Autocomplete.lua new file mode 100644 index 0000000..ad9ee38 --- /dev/null +++ b/.config/linux/system/module/common/nvim/key/Autocomplete.lua @@ -0,0 +1,5 @@ +-- Autocomplete. +rekey_input("", "") + +-- LSP autocomplete. +rekey_normal("", "lua vim.lsp.buf.code_action()") diff --git a/.config/linux/system/module/common/nvim/key/Buffer.lua b/.config/linux/system/module/common/nvim/key/Buffer.lua new file mode 100644 index 0000000..9c2f977 --- /dev/null +++ b/.config/linux/system/module/common/nvim/key/Buffer.lua @@ -0,0 +1,12 @@ +-- New empty buffer. +remap_normal("n", "enew") + +-- Close buffer. +function _buf_close() + pcall(vim.cmd, "w") + vim.cmd[[bp|sp|bn|bd!]] +end +rekey_normal("x", "lua _buf_close()") + +-- Close all hidden buffers. +rekey_normal("X", "BDelete hidden") diff --git a/.config/linux/system/module/common/nvim/key/Comment.lua b/.config/linux/system/module/common/nvim/key/Comment.lua new file mode 100644 index 0000000..3991e1d --- /dev/null +++ b/.config/linux/system/module/common/nvim/key/Comment.lua @@ -0,0 +1,5 @@ +-- Toggle comment for the selected line. +vim.keymap.set("n", "/", require("SingleComment").SingleComment, { expr = true }) + +-- Toggle comments for multiple lines. +vim.keymap.set("v", "/", require("SingleComment").Comment, {}) diff --git a/.config/linux/system/module/common/nvim/key/Common.lua b/.config/linux/system/module/common/nvim/key/Common.lua new file mode 100644 index 0000000..0645201 --- /dev/null +++ b/.config/linux/system/module/common/nvim/key/Common.lua @@ -0,0 +1,22 @@ +-- Write all we can and exit. Created this to drop non-writable stuff when piping to nvim. +function bye() + pcall(vim.cmd, "wa") + vim.cmd[[qa!]] +end + +-- Repeat previous command. +rekey_normal(".", "@:") +rekey_visual(".", "@:") + +-- Save everything. +rekey_normal("zz", "wa") + +-- Save all we can and leave. +rekey_normal("z", "lua bye()") + +-- Compatibility alias for visual selection. +rekey_normal("v", "v") + +-- Remap ; to :. +rekey_normal(";", ":") +rekey_visual(";", ":") diff --git a/.config/linux/system/module/common/nvim/key/Filetree.lua b/.config/linux/system/module/common/nvim/key/Filetree.lua new file mode 100644 index 0000000..fe19a3e --- /dev/null +++ b/.config/linux/system/module/common/nvim/key/Filetree.lua @@ -0,0 +1,2 @@ +-- Toggle file tree. +rekey_normal("1", "NvimTreeToggle") diff --git a/.config/linux/system/module/common/nvim/key/Fold.lua b/.config/linux/system/module/common/nvim/key/Fold.lua new file mode 100644 index 0000000..6186f05 --- /dev/null +++ b/.config/linux/system/module/common/nvim/key/Fold.lua @@ -0,0 +1,5 @@ +-- Toggle fold under cursor. +remap_normal("o", "za") + +-- Fold everything. +remap_normal("O", "zM") diff --git a/.config/linux/system/module/common/nvim/key/Gitsigns.lua b/.config/linux/system/module/common/nvim/key/Gitsigns.lua new file mode 100644 index 0000000..dffa62b --- /dev/null +++ b/.config/linux/system/module/common/nvim/key/Gitsigns.lua @@ -0,0 +1,2 @@ +-- Toggle Git inspection mode. +rekey_normal("g", "Gitsigns toggle_current_line_blameGitsigns toggle_word_diffGitsigns toggle_linehl") diff --git a/.config/nvim/lua/key/Leader.lua b/.config/linux/system/module/common/nvim/key/Leader.lua similarity index 86% rename from .config/nvim/lua/key/Leader.lua rename to .config/linux/system/module/common/nvim/key/Leader.lua index c47be11..b99ec09 100644 --- a/.config/nvim/lua/key/Leader.lua +++ b/.config/linux/system/module/common/nvim/key/Leader.lua @@ -1,5 +1,3 @@ -require("key/Rekey") - leader = " " vim.g.mapleader = leader diff --git a/.config/linux/system/module/common/nvim/key/Lsp.lua b/.config/linux/system/module/common/nvim/key/Lsp.lua new file mode 100644 index 0000000..e69de29 diff --git a/.config/linux/system/module/common/nvim/key/Navigation.lua b/.config/linux/system/module/common/nvim/key/Navigation.lua new file mode 100644 index 0000000..78e6a5d --- /dev/null +++ b/.config/linux/system/module/common/nvim/key/Navigation.lua @@ -0,0 +1,23 @@ +-- Switch windows. +rekey_normal("a", "h") +rekey_normal("d", "l") +rekey_normal("s", "j") +rekey_normal("w", "k") + +-- Switch buffers. +rekey_normal("E", "BufferLineMoveNext") +rekey_normal("Q", "BufferLineMovePrev") +rekey_normal("e", "BufferLineCycleNext") +rekey_normal("q", "BufferLineCyclePrev") + +-- Splits. +rekey_normal("\\", "vsplit") +rekey_normal("-", "split") +rekey_normal("=", "=") -- Equalize split sizes. +rekey_normal("c", "q") -- Close split. + +-- Resize splits. +rekey_normal("A", "4<") +rekey_normal("D", "4>") +rekey_normal("S", "2+") +rekey_normal("W", "2-") diff --git a/.config/linux/system/module/common/nvim/key/Rekey.lua b/.config/linux/system/module/common/nvim/key/Rekey.lua new file mode 100644 index 0000000..314e975 --- /dev/null +++ b/.config/linux/system/module/common/nvim/key/Rekey.lua @@ -0,0 +1,49 @@ +-- Base rekey function. +local function rekey(t, key, command) + vim.api.nvim_set_keymap(t, key, command, { noremap = true }) +end + +-- Base remap function. +local function remap(t, key, command) + vim.api.nvim_set_keymap(t, key, command, { noremap = false }) +end + +-- Rekey in normal mode. +function rekey_normal(key, command) + rekey("n", key, command) +end + +-- Rekey in input mode. +function rekey_input(key, command) + rekey("i", key, command) +end + +-- Rekey in visual mode. +function rekey_visual(key, command) + rekey("v", key, command) +end + +-- Rekey in terminal mode. +function rekey_terminal(key, command) + rekey("t", key, command) +end + +-- Remap in normal mode. +function remap_normal(key, command) + remap("n", key, command) +end + +-- Remap in input mode. +function remap_input(key, command) + remap("i", key, command) +end + +-- Remap in visual mode. +function remap_visual(key, command) + remap("v", key, command) +end + +-- Remap in terminal mode. +function remap_terminal(key, command) + remap("t", key, command) +end diff --git a/.config/linux/system/module/common/nvim/key/Sort.lua b/.config/linux/system/module/common/nvim/key/Sort.lua new file mode 100644 index 0000000..3b234ef --- /dev/null +++ b/.config/linux/system/module/common/nvim/key/Sort.lua @@ -0,0 +1,2 @@ +-- Sort visual selection alphabetically. +rekey_visual("A", ":'<,'>sort") diff --git a/.config/linux/system/module/common/nvim/key/Telescope.lua b/.config/linux/system/module/common/nvim/key/Telescope.lua new file mode 100644 index 0000000..b747f5e --- /dev/null +++ b/.config/linux/system/module/common/nvim/key/Telescope.lua @@ -0,0 +1,6 @@ +rekey_normal("fa", "Telescope") +rekey_normal("fb", "lua require('telescope.builtin').buffers()") +rekey_normal("ff", "lua require('telescope.builtin').find_files()") +rekey_normal("fg", "lua require('telescope.builtin').live_grep()") +rekey_normal("fh", "lua require('telescope.builtin').help_tags()") +rekey_normal("ft", "Telescope treesitter") diff --git a/.config/linux/system/module/common/nvim/key/Terminal.lua b/.config/linux/system/module/common/nvim/key/Terminal.lua new file mode 100644 index 0000000..359cc74 --- /dev/null +++ b/.config/linux/system/module/common/nvim/key/Terminal.lua @@ -0,0 +1,5 @@ +-- Open terminal window. +rekey_normal("4", "terminal") + +-- Detach from terminal with Esc key. +rekey_terminal("", "") diff --git a/.config/linux/system/module/common/nvim/key/Todo.lua b/.config/linux/system/module/common/nvim/key/Todo.lua new file mode 100644 index 0000000..7e84da8 --- /dev/null +++ b/.config/linux/system/module/common/nvim/key/Todo.lua @@ -0,0 +1,2 @@ +-- Toggle To-do window. +rekey_normal("3", "TroubleToggle todo") diff --git a/.config/linux/system/module/common/nvim/key/Trouble.lua b/.config/linux/system/module/common/nvim/key/Trouble.lua new file mode 100644 index 0000000..ea948e8 --- /dev/null +++ b/.config/linux/system/module/common/nvim/key/Trouble.lua @@ -0,0 +1,2 @@ +-- Toggle diagnostics window. +rekey_normal("2", "TroubleToggle document_diagnostics") diff --git a/.config/linux/system/module/common/nvim/key/Update.lua b/.config/linux/system/module/common/nvim/key/Update.lua new file mode 100644 index 0000000..f2fcca6 --- /dev/null +++ b/.config/linux/system/module/common/nvim/key/Update.lua @@ -0,0 +1,5 @@ +-- Update all command. +vim.api.nvim_create_user_command("Update", function (args) + vim.cmd("PackerUpdate") + vim.cmd("TSUpdate") +end, { desc = "Update everything." }) diff --git a/.config/linux/system/module/common/nvim/key/Whichkey.lua b/.config/linux/system/module/common/nvim/key/Whichkey.lua new file mode 100644 index 0000000..afb61aa --- /dev/null +++ b/.config/linux/system/module/common/nvim/key/Whichkey.lua @@ -0,0 +1,2 @@ +-- Show keymap help. +rekey_normal("?", "WhichKey") diff --git a/.config/linux/system/module/common/nvim/plugin/Align.lua b/.config/linux/system/module/common/nvim/plugin/Align.lua new file mode 100644 index 0000000..7db2b57 --- /dev/null +++ b/.config/linux/system/module/common/nvim/plugin/Align.lua @@ -0,0 +1,7 @@ +require("mini.align").setup { + mappings = { + start = "a", + -- start_with_preview = 'A', + }, +} + diff --git a/.config/linux/system/module/common/nvim/plugin/Autoclose.lua b/.config/linux/system/module/common/nvim/plugin/Autoclose.lua new file mode 100644 index 0000000..e932054 --- /dev/null +++ b/.config/linux/system/module/common/nvim/plugin/Autoclose.lua @@ -0,0 +1,13 @@ +require("autoclose").setup({ + keys = { + ["'"] = { escape = false, close = false, pair = "''", disabled_filetypes = {} }, + ["("] = { escape = true, close = true, pair = "()", disabled_filetypes = {} }, + ["<"] = { escape = true, close = true, pair = "<>", disabled_filetypes = {} }, + ["\""] = { escape = true, close = true, pair = "\"\"", disabled_filetypes = {} }, + ["`"] = { escape = true, close = true, pair = "``", disabled_filetypes = {} }, + ["{"] = { escape = true, close = true, pair = "{}", disabled_filetypes = {} }, + }, + -- options = { + -- disabled_filetypes = { "text", "markdown" }, + -- } +}) diff --git a/.config/linux/system/module/common/nvim/plugin/Bufferline.lua b/.config/linux/system/module/common/nvim/plugin/Bufferline.lua new file mode 100644 index 0000000..da65645 --- /dev/null +++ b/.config/linux/system/module/common/nvim/plugin/Bufferline.lua @@ -0,0 +1 @@ +require("bufferline").setup() diff --git a/.config/linux/system/module/common/nvim/plugin/Closebuffers.lua b/.config/linux/system/module/common/nvim/plugin/Closebuffers.lua new file mode 100644 index 0000000..a1f2906 --- /dev/null +++ b/.config/linux/system/module/common/nvim/plugin/Closebuffers.lua @@ -0,0 +1,7 @@ +require("close_buffers").setup({ + file_glob_ignore = {}, + file_regex_ignore = {}, + filetype_ignore = {}, + next_buffer_cmd = nil, + preserve_window_layout = { "this", "nameless" }, +}) diff --git a/.config/linux/system/module/common/nvim/plugin/Filetree.lua b/.config/linux/system/module/common/nvim/plugin/Filetree.lua new file mode 100644 index 0000000..8d61b72 --- /dev/null +++ b/.config/linux/system/module/common/nvim/plugin/Filetree.lua @@ -0,0 +1,36 @@ +-- Disable netrw at the very start of your init.lua. +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 + +local function my_on_attach(bufnr) + local api = require "nvim-tree.api" + + local function opts(desc) + return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } + end + + -- Default mappings. + api.config.mappings.default_on_attach(bufnr) + + -- Custom mappings. + vim.keymap.set('n', '', api.tree.change_root_to_node, opts('Cd into')) +end + +-- Set termguicolors to enable highlight groups. +vim.opt.termguicolors = true + +-- Setup nvim-tree. +require("nvim-tree").setup({ + on_attach = my_on_attach, + sort_by = "case_sensitive", + view = { + width = 30, + }, + renderer = { + group_empty = true, + }, + filters = { + dotfiles = false, + git_ignored = false + }, +}) diff --git a/.config/linux/system/module/common/nvim/plugin/Fold.lua b/.config/linux/system/module/common/nvim/plugin/Fold.lua new file mode 100644 index 0000000..b088a28 --- /dev/null +++ b/.config/linux/system/module/common/nvim/plugin/Fold.lua @@ -0,0 +1,3 @@ +vim.opt.foldexpr = "nvim_treesitter#foldexpr()" +vim.opt.foldlevel = 99 +vim.opt.foldmethod = "expr" diff --git a/.config/linux/system/module/common/nvim/plugin/Gitsigns.lua b/.config/linux/system/module/common/nvim/plugin/Gitsigns.lua new file mode 100644 index 0000000..c26b670 --- /dev/null +++ b/.config/linux/system/module/common/nvim/plugin/Gitsigns.lua @@ -0,0 +1,43 @@ +require("gitsigns").setup { + signs = { + add = { text = "│" }, + change = { text = "│" }, + changedelete = { text = "~" }, + delete = { text = "_" }, + topdelete = { text = "‾" }, + untracked = { text = "┆" }, + }, + linehl = false, + numhl = true, + signcolumn = false, + word_diff = false, + watch_gitdir = { + follow_files = true, + }, + attach_to_untracked = true, + current_line_blame = false, + current_line_blame_opts = { + delay = 1000, + ignore_whitespace = false, + virt_text = true, + virt_text_pos = "eol", + }, + current_line_blame_formatter = ", - ", + max_file_length = 40000, + sign_priority = 6, + status_formatter = nil, + update_debounce = 100, + preview_config = { + border = "single", + col = 1, + relative = "cursor", + row = 0, + style = "minimal", + }, + yadm = { + enable = false, + }, +} + +-- Set custom color. +vim.cmd("highlight gitsignscurrentlineblame guibg=#00000000 guifg=#aaaaaa") diff --git a/.config/linux/system/module/common/nvim/plugin/Gruvbox.lua b/.config/linux/system/module/common/nvim/plugin/Gruvbox.lua new file mode 100644 index 0000000..50c976d --- /dev/null +++ b/.config/linux/system/module/common/nvim/plugin/Gruvbox.lua @@ -0,0 +1 @@ +vim.cmd("colorscheme gruvbox-material") diff --git a/.config/linux/system/module/common/nvim/plugin/Indent.lua b/.config/linux/system/module/common/nvim/plugin/Indent.lua new file mode 100644 index 0000000..279f4f7 --- /dev/null +++ b/.config/linux/system/module/common/nvim/plugin/Indent.lua @@ -0,0 +1,6 @@ +-- Auto-detect indentation type. +require("indent-o-matic").setup { + max_lines = 1024, + skip_multiline = true, + standard_widths = { 2, 4, 8 }, +} diff --git a/.config/linux/system/module/common/nvim/plugin/Init.lua b/.config/linux/system/module/common/nvim/plugin/Init.lua new file mode 100644 index 0000000..8394b1a --- /dev/null +++ b/.config/linux/system/module/common/nvim/plugin/Init.lua @@ -0,0 +1,49 @@ +local ensure_packer = function() + local fn = vim.fn + local install_path = fn.stdpath("data").."/site/pack/packer/start/packer.nvim" + if fn.empty(fn.glob(install_path)) > 0 then + fn.system({"git", "clone", "--depth", "1", "https://git.voronind.com/mirror/packer.nvim.git", install_path}) + vim.cmd [[packadd packer.nvim]] + return true + end + return false +end + +local packer_bootstrap = ensure_packer() + +local available = function(commands) + for _, command in ipairs(commands) do + if vim.fn.executable(command) ~= 1 then + return false + end + end + return true +end + +return require("packer").startup(function(use) + use "https://git.voronind.com/mirror/SingleComment.nvim.git" + use "https://git.voronind.com/mirror/autoclose.nvim.git" + use "https://git.voronind.com/mirror/bufferline.nvim.git" + use "https://git.voronind.com/mirror/close-buffers.nvim.git" + use "https://git.voronind.com/mirror/gitsigns.nvim.git" + use "https://git.voronind.com/mirror/gruvbox-material.git" + use "https://git.voronind.com/mirror/indent-o-matic.git" + use "https://git.voronind.com/mirror/lualine.nvim.git" + use "https://git.voronind.com/mirror/mini.align.git" + use "https://git.voronind.com/mirror/nvim-lspconfig.git" + use "https://git.voronind.com/mirror/nvim-tree.lua.git" + use "https://git.voronind.com/mirror/nvim-treesitter.git" + use "https://git.voronind.com/mirror/nvim-web-devicons.git" + use "https://git.voronind.com/mirror/packer.nvim.git" + use "https://git.voronind.com/mirror/plenary.nvim.git" + use "https://git.voronind.com/mirror/telescope.nvim.git" + use "https://git.voronind.com/mirror/todo-comments.nvim.git" + use "https://git.voronind.com/mirror/tokyonight.nvim.git" + use "https://git.voronind.com/mirror/trouble.nvim.git" + use "https://git.voronind.com/mirror/which-key.nvim.git" + + -- Auto-install. + if packer_bootstrap then + require("packer").sync() + end +end) diff --git a/.config/linux/system/module/common/nvim/plugin/Lualine.lua b/.config/linux/system/module/common/nvim/plugin/Lualine.lua new file mode 100644 index 0000000..3029c4b --- /dev/null +++ b/.config/linux/system/module/common/nvim/plugin/Lualine.lua @@ -0,0 +1,40 @@ +require("lualine").setup { + options = { + -- theme = "ayu_mirage", + icons_enabled = true, + component_separators = { left = "", right = ""}, + section_separators = { left = "", right = ""}, + disabled_filetypes = { + statusline = {}, + winbar = {}, + }, + always_divide_middle = true, + globalstatus = false, + ignore_focus = {}, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + } + }, + 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 = {}, + }, + extensions = {}, + inactive_winbar = {}, + tabline = {}, + winbar = {}, +} diff --git a/.config/linux/system/module/common/nvim/plugin/Telescope.lua b/.config/linux/system/module/common/nvim/plugin/Telescope.lua new file mode 100644 index 0000000..d30fb98 --- /dev/null +++ b/.config/linux/system/module/common/nvim/plugin/Telescope.lua @@ -0,0 +1,11 @@ +require("telescope").setup{ + defaults = { + mappings = { + i = { + [""] = "which_key", + } + } + }, + extensions = { }, + pickers = { }, +} diff --git a/.config/linux/system/module/common/nvim/plugin/Todo.lua b/.config/linux/system/module/common/nvim/plugin/Todo.lua new file mode 100644 index 0000000..e583a45 --- /dev/null +++ b/.config/linux/system/module/common/nvim/plugin/Todo.lua @@ -0,0 +1,53 @@ +require("todo-comments").setup { + sign_priority = 8, + signs = false, + keywords = { + FIX = { + alt = { "FIXME", "BUG", "FIXIT", "ISSUE" }, + color = "error", + icon = " ", + }, + HACK = { icon = " ", color = "warning" }, + NOTE = { icon = " ", color = "hint", alt = { "INFO" } }, + PERF = { icon = " ", alt = { "OPTIM", "PERFORMANCE", "OPTIMIZE" } }, + TEST = { icon = "⏲ ", color = "test", alt = { "TESTING", "PASSED", "FAILED" } }, + TODO = { icon = " ", color = "info" }, + WARN = { icon = " ", color = "warning", alt = { "WARNING", "XXX" } }, + }, + gui_style = { + bg = "BOLD", + fg = "NONE", + }, + merge_keywords = true, + highlight = { + after = "fg", + before = "", + comments_only = true, + exclude = {}, + keyword = "wide", + max_line_len = 400, + multiline = true, + multiline_context = 10, + multiline_pattern = "^.", + pattern = [[.*<(KEYWORDS)\s*:]], + }, + colors = { + default = { "Identifier", "#7C3AED" }, + error = { "DiagnosticError", "ErrorMsg", "#DC2626" }, + hint = { "DiagnosticHint", "#10B981" }, + info = { "DiagnosticInfo", "#2563EB" }, + test = { "Identifier", "#FF00FF" }, + warning = { "DiagnosticWarn", "WarningMsg", "#FBBF24" }, + }, + search = { + command = "rg", + args = { + "--color=never", + "--no-heading", + "--with-filename", + "--line-number", + "--column", + }, + pattern = [[\b(KEYWORDS):]], + }, +} diff --git a/.config/linux/system/module/common/nvim/plugin/Tokyonight.lua b/.config/linux/system/module/common/nvim/plugin/Tokyonight.lua new file mode 100644 index 0000000..667ee34 --- /dev/null +++ b/.config/linux/system/module/common/nvim/plugin/Tokyonight.lua @@ -0,0 +1,23 @@ +require("tokyonight").setup({ + light_style = "night", + style = "night", + terminal_colors = true, + transparent = false, + styles = { + comments = { italic = true }, + floats = "dark", + functions = {}, + keywords = { italic = true }, + sidebars = "dark", + variables = {}, + }, + day_brightness = 0.3, + dim_inactive = false, + hide_inactive_statusline = false, + lualine_bold = false, + on_colors = function(colors) end, + on_highlights = function(highlights, colors) end, + sidebars = { "qf", "help" }, +}) + +-- vim.cmd[[colorscheme tokyonight]] diff --git a/.config/linux/system/module/common/nvim/plugin/Treesitter.lua b/.config/linux/system/module/common/nvim/plugin/Treesitter.lua new file mode 100644 index 0000000..ecf3eca --- /dev/null +++ b/.config/linux/system/module/common/nvim/plugin/Treesitter.lua @@ -0,0 +1,19 @@ +require("nvim-treesitter.configs").setup { + auto_install = true, + -- ensure_installed = "all", + sync_install = false, + highlight = { + additional_vim_regex_highlighting = false, + enable = true, + use_languagetree = true, + }, + indent = { + enable = true, + }, + autotag = { + enable = true + }, + rainbow = { + enable = true + }, +} diff --git a/.config/linux/system/module/common/nvim/plugin/Trouble.lua b/.config/linux/system/module/common/nvim/plugin/Trouble.lua new file mode 100644 index 0000000..38ef1e9 --- /dev/null +++ b/.config/linux/system/module/common/nvim/plugin/Trouble.lua @@ -0,0 +1 @@ +require("trouble").setup() diff --git a/.config/linux/system/module/common/nvim/plugin/lsp/Kotlin.lua b/.config/linux/system/module/common/nvim/plugin/lsp/Kotlin.lua new file mode 100644 index 0000000..e960df6 --- /dev/null +++ b/.config/linux/system/module/common/nvim/plugin/lsp/Kotlin.lua @@ -0,0 +1,3 @@ +local lspconfig = require("lspconfig") + +lspconfig.kotlin_language_server.setup {} diff --git a/.config/linux/system/module/common/nvim/plugin/lsp/Python.lua b/.config/linux/system/module/common/nvim/plugin/lsp/Python.lua new file mode 100644 index 0000000..5642869 --- /dev/null +++ b/.config/linux/system/module/common/nvim/plugin/lsp/Python.lua @@ -0,0 +1,3 @@ +local lspconfig = require("lspconfig") + +lspconfig.pyright.setup {} diff --git a/.config/linux/system/module/common/nvim/plugin/lsp/Rust.lua b/.config/linux/system/module/common/nvim/plugin/lsp/Rust.lua new file mode 100644 index 0000000..2ca5362 --- /dev/null +++ b/.config/linux/system/module/common/nvim/plugin/lsp/Rust.lua @@ -0,0 +1,16 @@ +local lspconfig = require("lspconfig") + +lspconfig.rust_analyzer.setup { + settings = { + ["rust-analyzer"] = { + rustfmt = { + extraArgs = { + "--config", + "hard_tabs=true", + } + } + }, + }, +} + +vim.g.rust_recommended_style = false diff --git a/.config/linux/system/module/common/nvim/plugin/lsp/Tex.lua b/.config/linux/system/module/common/nvim/plugin/lsp/Tex.lua new file mode 100644 index 0000000..bc0fb7a --- /dev/null +++ b/.config/linux/system/module/common/nvim/plugin/lsp/Tex.lua @@ -0,0 +1,60 @@ +local lspconfig = require('lspconfig') +local config = { + filetypes = { + "bib", + "gitcommit", + "markdown", + "org", + "pandoc", + "plaintex", + "rnoweb", + "rst", + "tex", + "text", + }, + settings = { + ["ltex"] = { + language = "auto" + } + } +} + +lspconfig.ltex.setup(config) + +-- Use TeX LSP for spellcheck. +vim.api.nvim_create_user_command("SCOn", function (args) + lspconfig.ltex.setup(config) +end, { desc = "Enable spellcheck." }) + +vim.api.nvim_create_user_command("SCOff", function (args) + lspconfig.ltex.setup { filetypes = {} } +end, { desc = "Disable spellcheck." }) + +vim.api.nvim_create_user_command("SCLangRU", function (args) + config.settings['ltex'].language = "ru-RU" + lspconfig.ltex.setup(config) +end, { desc = "Set spellcheck to Russian." }) + +vim.api.nvim_create_user_command("SCLangEN", function (args) + config.settings['ltex'].language = "en-US" + lspconfig.ltex.setup(config) +end, { desc = "Set spellcheck to English." }) + +vim.api.nvim_create_user_command("SCLangAuto", function (args) + config.settings['ltex'].language = "auto" + lspconfig.ltex.setup(config) +end, { desc = "Set spellcheck to Auto." }) + +vim.api.nvim_create_user_command("SCForce", function (args) + vim.cmd("setfiletype text") + vim.cmd("SCOn") +end, { desc = "Set buffer type to text." }) + +vim.api.nvim_create_user_command("SCReset", function (args) + vim.cmd("filetype detect") + vim.cmd("SCLangAuto") +end, { desc = "Set buffer type to auto." }) + +vim.api.nvim_create_user_command("SCInfo", function (args) + vim.cmd("LspInfo") +end, { desc = "Show info about spellcheck." })