From d3cad47f99b1d945b06a81e3142649474b1d7f71 Mon Sep 17 00:00:00 2001 From: janabhumi Date: Sun, 18 Sep 2022 14:04:02 +0300 Subject: [PATCH] home/nvim: clean up prev config --- home/progs/default.nix | 2 +- home/progs/nvim.nix | 34 +++++ home/progs/nvim/coc_settings.nix | 24 ---- home/progs/nvim/config.vim | 3 - home/progs/nvim/custom_plugins.nix | 24 ---- home/progs/nvim/default.nix | 84 ------------ home/progs/nvim/lua/basic.lua | 210 ----------------------------- home/progs/nvim/lua/coc.lua | 58 -------- home/progs/nvim/lua/plugins.lua | 92 ------------- home/progs/nvim/nvim_nightly.nix | 17 --- outputs/home.nix | 6 +- 11 files changed, 36 insertions(+), 518 deletions(-) create mode 100644 home/progs/nvim.nix delete mode 100644 home/progs/nvim/coc_settings.nix delete mode 100644 home/progs/nvim/config.vim delete mode 100644 home/progs/nvim/custom_plugins.nix delete mode 100644 home/progs/nvim/default.nix delete mode 100644 home/progs/nvim/lua/basic.lua delete mode 100644 home/progs/nvim/lua/coc.lua delete mode 100644 home/progs/nvim/lua/plugins.lua delete mode 100644 home/progs/nvim/nvim_nightly.nix diff --git a/home/progs/default.nix b/home/progs/default.nix index bc37ec9..9f43e1f 100644 --- a/home/progs/default.nix +++ b/home/progs/default.nix @@ -4,7 +4,7 @@ ./git.nix ./himalaya.nix ./hledger.nix - ./nvim + ./nvim.nix ./pass.nix ./vifm ./zoxide.nix diff --git a/home/progs/nvim.nix b/home/progs/nvim.nix new file mode 100644 index 0000000..40e6b90 --- /dev/null +++ b/home/progs/nvim.nix @@ -0,0 +1,34 @@ +{ lib, config, pkgs, ... }: + +with lib; + +let + cfg = config.progs.nvim; + + myneovim = pkgs.myneovim.override { + enableDevIcons = true; + }; +in +{ + options.progs.nvim = { + enable = mkOption { + type = types.bool; + default = false; + description = "Add and configure neovim"; + }; + + default = mkOption { + type = types.bool; + default = false; + description = "Set neovim as default editor"; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ myneovim ]; + + home.sessionVariables = mkIf cfg.default { + EDITOR = "nvim"; + }; + }; +} diff --git a/home/progs/nvim/coc_settings.nix b/home/progs/nvim/coc_settings.nix deleted file mode 100644 index ef43ff9..0000000 --- a/home/progs/nvim/coc_settings.nix +++ /dev/null @@ -1,24 +0,0 @@ -{ - # General - coc.source = { - around.enable = true; - buffer.enable = true; - file.enable = false; - }; - - # LSP - languageserver = { - nix = { - command = "rnix-lsp"; - filetypes = [ "nix" ]; - }; - }; - - # Rust - "rust-analyzer.server.path" = "rust-analyzer"; - "rust-analyzer.updates.prompt" = false; - "rust-analyzer.updates.checkOnStartup" = false; - "rust-analyzer.checkOnSave.enable" = true; - "rust-analyzer.checkOnSave.command" = "clippy"; - "rust-analyzer.cargo.autoreload" = true; -} diff --git a/home/progs/nvim/config.vim b/home/progs/nvim/config.vim deleted file mode 100644 index 67533c9..0000000 --- a/home/progs/nvim/config.vim +++ /dev/null @@ -1,3 +0,0 @@ -lua require 'basic' -lua require 'plugins' -lua require 'coc' diff --git a/home/progs/nvim/custom_plugins.nix b/home/progs/nvim/custom_plugins.nix deleted file mode 100644 index 2f5314a..0000000 --- a/home/progs/nvim/custom_plugins.nix +++ /dev/null @@ -1,24 +0,0 @@ -{ buildVimPlugin }: - -# To calculate sha256 hash use the following command: -# nix-prefetch-url --unpack - -{ - material-vim = buildVimPlugin { - name = "material-vim"; - src = builtins.fetchTarball { - name = "material-vim-2021-12-10"; - url = https://github.com/kaicataldo/material.vim/archive/445534b2db7f7ec3dc088eae21c86ff0e9bb19de.tar.gz; - sha256 = "1lwlr6haj1damzmk6i6a1la7vql4y1wmb62iqvm6xgy2svr0s36i"; - }; - }; - - blamer-nvim = buildVimPlugin { - name = "blamer-nvim"; - src = builtins.fetchTarball { - name = "blamer-nvim-2021-11-17"; - url = https://github.com/APZelos/blamer.nvim/archive/f4eb22a9013642c411725fdda945ae45f8d93181.tar.gz; - sha256 = "1czjagkfjw57f2nvjjgbma1gcy1ylcd68dyfc5ivr2wc6fdw5lks"; - }; - }; -} diff --git a/home/progs/nvim/default.nix b/home/progs/nvim/default.nix deleted file mode 100644 index 7c6deaf..0000000 --- a/home/progs/nvim/default.nix +++ /dev/null @@ -1,84 +0,0 @@ -{ lib, config, pkgs, ... }: - -with lib; - -let - cfg = config.progs.nvim; - - customPlugins = pkgs.callPackage ./custom_plugins.nix { - inherit (pkgs.vimUtils) buildVimPlugin; - }; - - plugins = pkgs.vimPlugins // customPlugins; - - myVimPlugins = with plugins; [ - coc-tsserver # typescript LSP - coc-eslint # eslint LSP - coc-rust-analyzer # rust LSP - - editorconfig-vim # use project .editorconfig to configure editor - lightline-vim # configurable status line - material-vim # modern theme with true colors support - vim-nix # nix support - vim-easymotion # highlights keys to move quickly - vim-gitgutter # shows git diff markers in the sign column - nerdtree # tree explorer - nerdtree-git-plugin # shows files git status on the NerdTree - neoformat # formating code - nvim-treesitter # treesitter configurations and abstraction layer - fzf-vim # fuzzy finder - blamer-nvim # A git blame plugin - ]; - - # Additional language servers that we should install mannually - lspPackages = with pkgs; [ rnix-lsp ]; - # Additional tools - fzfToolsPackages = with pkgs; [ fzf ripgrep ]; - - additionalPackages = lspPackages ++ fzfToolsPackages; - - vimConfig = builtins.readFile ./config.vim; - cocConfig = import ./coc_settings.nix; -in -{ - options.progs.nvim = { - enable = mkOption { - type = types.bool; - default = false; - description = "Add and configure neovim"; - }; - - default = mkOption { - type = types.bool; - default = false; - description = "Set neovim as default editor"; - }; - }; - - config = mkIf cfg.enable { - home.packages = with pkgs; [ myneovim ]; - /* - home.packages = additionalPackages; - - programs.neovim = { - enable = true; - extraConfig = vimConfig; - plugins = myVimPlugins; - viAlias = true; - vimAlias = true; - coc = { - enable = true; - settings = cocConfig; - }; - }; - - xdg.configFile = { - "nvim/lua".source = ./lua; - }; - */ - - home.sessionVariables = mkIf cfg.default { - EDITOR = "nvim"; - }; - }; -} diff --git a/home/progs/nvim/lua/basic.lua b/home/progs/nvim/lua/basic.lua deleted file mode 100644 index bcc278c..0000000 --- a/home/progs/nvim/lua/basic.lua +++ /dev/null @@ -1,210 +0,0 @@ -------------------------------------------------------------------------------- --- --- Basic Settings --- - -vim.cmd("filetype off") - --- Leaders -vim.g.mapleader = "," -vim.g.maplocalleader = "-" - --- Better Unix support -vim.opt.viewoptions = { "folds", "options", "cursor", "unix", "slash" } -vim.opt.encoding = "utf-8" - --- True color support -vim.opt.termguicolors = true - --- Theme (required plugin 'material-vim') --- Available styles: default, planight, ocean, lighter --- darker, default-community, palenight-community, ocean-community, --- lighter-community, darker-community -vim.g.material_theme_style = "default" -vim.g.lightline = { colorscheme = "material_vim" } -vim.cmd("colorscheme material") - --- Other options -vim.cmd("syntax on") -vim.opt.backspace = { "indent", "eol", "start" } -vim.opt.laststatus = 2 -vim.opt.showmode = false - --- Tabs as spaces -vim.opt.expandtab = true -vim.opt.tabstop = 2 -vim.opt.softtabstop = 2 -vim.opt.shiftwidth = 2 - --- Fixes broken cursor on Linux -vim.opt.guicursor = "" - --- Disable mouse / touchpad -vim.opt.mouse = "" - --- Incremental substitutin -vim.opt.inccommand = "split" - -------------------------------------------------------------------------------- --- --- General editor options --- - --- Hide files when leaving them. -vim.opt.hidden = true --- Show line numbers. -vim.opt.number = true --- Minimum line number column width. -vim.opt.numberwidth = 1 --- Number of screen lines to use for the commandline. -vim.opt.cmdheight = 2 --- Lines length limit (0 if no limit). -vim.opt.textwidth = 0 --- Don't cut lines in the middle of a work. -vim.opt.linebreak = true --- Show matching parenthesis. -vim.opt.showmatch = true --- Time during which the matching parenthesis is shown. -vim.opt.matchtime = 2 --- Sensible default line auto cutting and formatting. -vim.opt.formatoptions = "jtcrq" --- Copy/Past to/from clipboard. -vim.opt.clipboard = "unnamedplus" --- Highlight line cursor is currently on. -vim.opt.cursorline = true --- Invisible characters representation when :set list -vim.opt.listchars = { - tab = "→ ", - trail = "~", - nbsp = "␣", - eol = "¬", -} - --- Search --- Incremental search. -vim.opt.incsearch = true --- Case insensitive. -vim.opt.ignorecase = true --- Case insensitive if no uppercase letter in pattern, case sensitive otherwise. -vim.opt.smartcase = true - --- Spell -vim.opt.spelllang = "en,ru" - --- Fold level -vim.opt.foldlevel = 99 -vim.opt.foldlevelstart = 99 -vim.opt.foldminlines = 3 -vim.opt.foldnestmax = 5 - -------------------------------------------------------------------------------- --- --- File type specified --- -local bufReadFile = { "BufNewFile", "BufRead" } - --- Set up a line limiter for each lang -local line_limiter_augroup = vim.api.nvim_create_augroup("line_limiter", {}) -local function set_line_limiter(limit, patterns) - vim.api.nvim_create_autocmd(bufReadFile, { - pattern = patterns, - group = line_limiter_augroup, - callback = function() - vim.wo.colorcolumn = tostring(limit) - end, - }) -end - -set_line_limiter(101, { - "*.nix", - "*.vim", - "*.lua", - "*.ts", - "*.tsx", - "*.js", - "*.jsx", - "*.rs", -}) -set_line_limiter(81, { - "*.json", - "*.yml", - "*.yaml", - "*.md", - "*.html", - "*.css", -}) - --- Spell check for markdown files -local spell_check_augroup = vim.api.nvim_create_augroup("spell_check", {}) -vim.api.nvim_create_autocmd(bufReadFile, { - pattern = { "*.md" }, - group = spell_check_augroup, - callback = function() - vim.wo.spell = true - end, -}) - --- Set up fold method for each lang -local folding_augroup = vim.api.nvim_create_augroup("folding", {}) -vim.api.nvim_create_autocmd(bufReadFile, { - group = folding_augroup, - pattern = { - "*.js", - "*.jsx", - "*.ts", - "*.tsx", - }, - callback = function() - vim.cmd("syntax on") - vim.wo.foldmethod = "syntax" - end, -}) - -------------------------------------------------------------------------------- --- --- Bindings --- -local function clear_search_hl() - vim.opt.hlsearch = false -end -vim.keymap.set("n", "", clear_search_hl, { desc = "Clear search highlighting" }) - --- Enable fast navigation between windows -vim.keymap.set("n", "", "h") -vim.keymap.set("n", "", "l") -vim.keymap.set("n", "", "j") -vim.keymap.set("n", "", "k") - --- Disable the annoying and useless ex-mode -vim.keymap.set("n", "Q", "") -vim.keymap.set("n", "gQ", "") - --- Disable arrow keys -vim.keymap.set("n", "", "") -vim.keymap.set("n", "", "") -vim.keymap.set("n", "", "") -vim.keymap.set("n", "", "") -vim.keymap.set("v", "", "") -vim.keymap.set("v", "", "") -vim.keymap.set("v", "", "") -vim.keymap.set("v", "", "") --- ... instead of insert mode for rus lang and popups --- vim.keymap.set("i", "", "") --- vim.keymap.set("i", "", "") --- vim.keymap.set("i", "", "") --- vim.keymap.set("i", "", "") - --- Disable page up / down -vim.keymap.set("n", "", "") -vim.keymap.set("n", "", "") -vim.keymap.set("v", "", "") -vim.keymap.set("v", "", "") -vim.keymap.set("i", "", "") -vim.keymap.set("i", "", "") - -------------------------------------------------------------------------------- --- --- Abbreviatures --- -vim.cmd("cabbrev bsp belowright split") -vim.cmd("cabbrev rvsp belowright vsplit") diff --git a/home/progs/nvim/lua/coc.lua b/home/progs/nvim/lua/coc.lua deleted file mode 100644 index 23368b1..0000000 --- a/home/progs/nvim/lua/coc.lua +++ /dev/null @@ -1,58 +0,0 @@ --- Smaller updatetime for CursorHold & CursorHoldI -vim.opt.updatetime = 300 - --- Coc don't use completeopt -vim.opt.completeopt = {} --- don't give |ins-completion-menu| messages. -vim.opt.shortmess:append("c") - --- always show signcolumns -vim.opt.signcolumn = "yes" - --- Some server have issues with backup files, see coc#649 -vim.opt.backup = false -vim.opt.writebackup = false - --- Better display for messages -vim.opt.cmdheight = 2 - --- Use for trigger completion. -vim.keymap.set("i", "", vim.fn["coc#refresh"], { - silent = true, - expr = true, -}) - --- Use for confirm completion, `u` means break undo chain at current --- position. Coc only does snippet and additional edit on confirm. -local function confirm_coc_completion() - if vim.call("coc#pum#visible") == 1 then - vim.call("coc#pum#confirm") - return "" - else - return "" - end -end -vim.keymap.set("i", "", confirm_coc_completion, { expr = true, silent = true }) - -local sr_opts = { silent = true, remap = true } --- Use `[c` and `]c` for navigate diagnostics -vim.keymap.set("n", "[c", "(coc-diagnostic-prev)", sr_opts) -vim.keymap.set("n", "]c", "(coc-diagnostic-next)", sr_opts) - --- Remap keys for gotos -vim.keymap.set("n", "gd", "(coc-definition)", sr_opts) -vim.keymap.set("n", "gy", "(coc-type-definition)", sr_opts) -vim.keymap.set("n", "gi", "(coc-implementation)", sr_opts) -vim.keymap.set("n", "gr", "(coc-references)", sr_opts) - --- Remap for do code action of current line -vim.keymap.set("n", "a", "(coc-codeaction)") --- Remap for rename current word -vim.keymap.set("n", "n", "(coc-rename)") - --- Mapping for CocList -vim.keymap.set("n", "cl", ":CocList") -vim.keymap.set("n", "cd", ":CocList diagnostics") -vim.keymap.set("n", "cc", ":CocList commands") -vim.keymap.set("n", "co", ":CocList outline") -vim.keymap.set("n", "cs", ":CocList symbols") diff --git a/home/progs/nvim/lua/plugins.lua b/home/progs/nvim/lua/plugins.lua deleted file mode 100644 index 690b3f0..0000000 --- a/home/progs/nvim/lua/plugins.lua +++ /dev/null @@ -1,92 +0,0 @@ -------------------------------------------------------------------------------- --- --- NerdTree --- - -vim.g.NERDTreeDirArrowExpandable = "▸" -vim.g.NERDTreeDirArrowCollapsible = "▾" - -vim.g.NERDTreeMiniamlUI = 1 -vim.g.NERDTreeDirArrows = 1 - --- Nerdtree git plugin symbols -vim.g.NERDTreeGitStatusIndicatorMapCustom = { - Modified = "ᵐ", - Staged = "ˢ", - Untracked = "ᵘ", - Renamed = "ʳ", - Unmerged = "ᶴ", - Deleted = "ˣ", - Dirty = "˜", - Clean = "ᵅ", - Unknown = "?", -} - -vim.keymap.set("n", "nt", ":NERDTreeToggle") -vim.keymap.set("n", "nf", ":NERDTreeFind") - -------------------------------------------------------------------------------- --- --- NeoFormat --- -vim.g.neoformat_try_node_exe = 1 -vim.g.neoformat_only_msg_on_error = 1 -vim.g.neoformat_enabled_markdown = { "denofmt" } - -vim.cmd([[ -aug fmt - au! - au BufWritePre * try | undojoin | Neoformat | catch /E790/ | Neoformat | endtry -aug END -]]) ---[[ TODO: need to investigate how implement it in lua -local format_augroup = vim.api.nvim_create_augroup('format', {}) -vim.api.nvim_create_autocmd('BufWritePre', { - pattern = '*', - group = spell_check_augroup, - callback = function () - local ok, _ = pcall(function () - vim.fn.undojoin(); - vim.cmd'NeoFormat'; - end) - - if not ok then vim.cmd'NeoFormat' end - end -}) -]] --- - -------------------------------------------------------------------------------- --- --- GitGutter --- -vim.g.gitgutter_sign_priority = 1 -vim.g.gitgutter_set_sign_backgrounds = 0 -vim.g.gitgutter_map_keys = 0 - -vim.keymap.set("n", "ghp", ":GitGutterPreviewHunk") - -------------------------------------------------------------------------------- --- --- TreeSitter --- -require("nvim-treesitter.configs").setup({ - -- A list of parser names, or "all" - ensure_installed = { - "typescript", - "tsx", - "rust", - "haskell", - }, - - -- Install parsers synchronously (only applied to `ensure_installed`) - sync_install = false, - - highlight = { - enable = true, - }, - - indent = { - enable = true, - }, -}) diff --git a/home/progs/nvim/nvim_nightly.nix b/home/progs/nvim/nvim_nightly.nix deleted file mode 100644 index d41ee69..0000000 --- a/home/progs/nvim/nvim_nightly.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ pkgs }: - -pkgs.neovim-unwrapped.overrideAttrs ( - old: { - name = "neovim-nightly"; - version = "nightly"; - - src = pkgs.fetchFromGitHub { - owner = "neovim"; - repo = "neovim"; - rev = "f17d88c47a6a647f2230a61e7cd952926abc4473"; - sha256 = "0lgbf90sbachdag1zm9pmnlbn35964l3khs27qy4462qzpqyi9fi"; - }; - - buildInputs = old.buildInputs ++ [ pkgs.tree-sitter ]; - } -) diff --git a/outputs/home.nix b/outputs/home.nix index b9acf0c..1370bdb 100644 --- a/outputs/home.nix +++ b/outputs/home.nix @@ -7,11 +7,7 @@ let inherit system; overlays = [ - (final: prev: { - myneovim = inputs.myneovim.packages.${system}.default.override { - enableDevIcons = true; - }; - }) + inputs.myneovim.overlays.${system} ]; }; in