home/nvim: clean up prev config

This commit is contained in:
Dmitriy Pleshevskiy 2022-09-18 14:04:02 +03:00
parent a2ba7eee97
commit d3cad47f99
Signed by: pleshevskiy
GPG key ID: 1B59187B161C0215
11 changed files with 36 additions and 518 deletions

View file

@ -4,7 +4,7 @@
./git.nix
./himalaya.nix
./hledger.nix
./nvim
./nvim.nix
./pass.nix
./vifm
./zoxide.nix

34
home/progs/nvim.nix Normal file
View file

@ -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";
};
};
}

View file

@ -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;
}

View file

@ -1,3 +0,0 @@
lua require 'basic'
lua require 'plugins'
lua require 'coc'

View file

@ -1,24 +0,0 @@
{ buildVimPlugin }:
# To calculate sha256 hash use the following command:
# nix-prefetch-url --unpack <URL>
{
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";
};
};
}

View file

@ -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";
};
};
}

View file

@ -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", "<C-z>", clear_search_hl, { desc = "Clear search highlighting" })
-- Enable fast navigation between windows
vim.keymap.set("n", "<C-h>", "<C-W>h")
vim.keymap.set("n", "<C-l>", "<C-W>l")
vim.keymap.set("n", "<C-j>", "<C-W>j")
vim.keymap.set("n", "<C-k>", "<C-W>k")
-- Disable the annoying and useless ex-mode
vim.keymap.set("n", "Q", "<nop>")
vim.keymap.set("n", "gQ", "<nop>")
-- Disable arrow keys
vim.keymap.set("n", "<Up>", "<nop>")
vim.keymap.set("n", "<Down>", "<nop>")
vim.keymap.set("n", "<Left>", "<nop>")
vim.keymap.set("n", "<Right>", "<nop>")
vim.keymap.set("v", "<Up>", "<nop>")
vim.keymap.set("v", "<Down>", "<nop>")
vim.keymap.set("v", "<Left>", "<nop>")
vim.keymap.set("v", "<Right>", "<nop>")
-- ... instead of insert mode for rus lang and popups
-- vim.keymap.set("i", "<Up>", "<nop>")
-- vim.keymap.set("i", "<Down>", "<nop>")
-- vim.keymap.set("i", "<Left>", "<nop>")
-- vim.keymap.set("i", "<Right>", "<nop>")
-- Disable page up / down
vim.keymap.set("n", "<PageUp>", "<nop>")
vim.keymap.set("n", "<PageDown>", "<nop>")
vim.keymap.set("v", "<PageUp>", "<nop>")
vim.keymap.set("v", "<PageDown>", "<nop>")
vim.keymap.set("i", "<PageUp>", "<nop>")
vim.keymap.set("i", "<PageDown>", "<nop>")
-------------------------------------------------------------------------------
--
-- Abbreviatures
--
vim.cmd("cabbrev bsp belowright split")
vim.cmd("cabbrev rvsp belowright vsplit")

View file

@ -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 <c-space> for trigger completion.
vim.keymap.set("i", "<C-space>", vim.fn["coc#refresh"], {
silent = true,
expr = true,
})
-- Use <cr> for confirm completion, `<C-g>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 "<CR>"
end
end
vim.keymap.set("i", "<CR>", 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", "<Plug>(coc-diagnostic-prev)", sr_opts)
vim.keymap.set("n", "]c", "<Plug>(coc-diagnostic-next)", sr_opts)
-- Remap keys for gotos
vim.keymap.set("n", "gd", "<Plug>(coc-definition)", sr_opts)
vim.keymap.set("n", "gy", "<Plug>(coc-type-definition)", sr_opts)
vim.keymap.set("n", "gi", "<Plug>(coc-implementation)", sr_opts)
vim.keymap.set("n", "gr", "<Plug>(coc-references)", sr_opts)
-- Remap for do code action of current line
vim.keymap.set("n", "<localleader>a", "<Plug>(coc-codeaction)")
-- Remap for rename current word
vim.keymap.set("n", "<localleader>n", "<Plug>(coc-rename)")
-- Mapping for CocList
vim.keymap.set("n", "<localleader>cl", ":CocList<CR>")
vim.keymap.set("n", "<localleader>cd", ":CocList diagnostics<CR>")
vim.keymap.set("n", "<localleader>cc", ":CocList commands<CR>")
vim.keymap.set("n", "<localleader>co", ":CocList outline<CR>")
vim.keymap.set("n", "<localleader>cs", ":CocList symbols<CR>")

View file

@ -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", "<leader>nt", ":NERDTreeToggle<CR>")
vim.keymap.set("n", "<leader>nf", ":NERDTreeFind<CR>")
-------------------------------------------------------------------------------
--
-- 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", "<leader>ghp", ":GitGutterPreviewHunk<CR>")
-------------------------------------------------------------------------------
--
-- 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,
},
})

View file

@ -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 ];
}
)

View file

@ -7,11 +7,7 @@ let
inherit system;
overlays = [
(final: prev: {
myneovim = inputs.myneovim.packages.${system}.default.override {
enableDevIcons = true;
};
})
inputs.myneovim.overlays.${system}
];
};
in