Migrate nvim config

This commit is contained in:
2023-01-02 23:58:41 +00:00
parent 903cbdc9da
commit 447503fadf
10 changed files with 27 additions and 19 deletions

View File

@ -3,7 +3,7 @@
./options.nix
./desktop/firefox.nix
./desktop/gnome.nix
./editors/neovim.nix
./editors/neovim
./editors/vscode.nix
./security/gpg.nix
./security/pass.nix

View File

@ -1,18 +0,0 @@
{ config, lib, pkgs, ... }:
with lib;
with lib.my;
let cfg = config.modules.editors.neovim;
in {
options.modules.editors.neovim = {
enable = mkBoolOpt false;
};
config = mkIf cfg.enable {
home.programs.neovim = {
enable = true;
vimAlias = true;
vimdiffAlias = true;
};
};
}

View File

@ -0,0 +1,26 @@
{ config, lib, pkgs, ... }:
with lib;
with lib.my;
let cfg = config.modules.editors.neovim;
in {
options.modules.editors.neovim = {
enable = mkBoolOpt false;
};
config = mkIf cfg.enable {
user.packages = with pkgs; [
neovim
];
home.configFile = {
"nvim/init.lua" = { source = ./init.lua; };
"nvim/lua" = { source = ./lua; recursive = true; };
};
environment.shellAliases = {
vim = "nvim";
v = "nvim";
};
};
}

View File

@ -0,0 +1,4 @@
require("config.core")
require("config.keymap")
require("config.plugins")

View File

@ -0,0 +1,35 @@
local o = vim.opt
local wo = vim.wo
local bo = vim.bo
-- Global dirs
local cachedir = os.getenv("XDG_CACHE_HOME")
o.backupdir = cachedir .. "/nvim/backup/"
o.directory = cachedir .. "/nvim/swap/"
o.undodir = cachedir .. "/nvim/undo/"
-- Global
o.breakindent = true
o.clipboard = "unnamedplus"
o.compatible = false
o.encoding = "utf-8"
o.expandtab = true
o.hidden = true
o.hlsearch = false
o.ignorecase = true
o.laststatus = 2
o.listchars = { eol = '', tab = '', trail = '·' }
o.relativenumber = true
o.shiftwidth = 2
o.showmode = false
o.smartcase = true
o.smarttab = true
o.softtabstop = 2
o.synmaxcol = 150
o.tabstop = 4
o.undofile = true
o.wildmenu = true
-- Window
-- Buffer

View File

@ -0,0 +1,35 @@
local keymap = vim.keymap.set
local opts = { noremap = true, silent = true }
vim.g.mapleader = ","
-- Modes
-- Normal = "n",
-- Insert = "i",
-- Visual = "v",
-- Visual Block = "x",
-- Term = "t",
-- Command = "c"
keymap("n", "<Left>", "<Nop>", opts)
keymap("n", "<Right>", "<Nop>", opts)
keymap("n", "<Up>", "<Nop>", opts)
keymap("n", "<Down>", "<Nop>", opts)
keymap("n", "<C-h>", "<C-w>h", { noremap = true })
keymap("n", "<C-j>", "<C-w>j", { noremap = true })
keymap("n", "<C-k>", "<C-w>k", { noremap = true })
keymap("n", "<C-l>", "<C-w>l", { noremap = true })
keymap("n", "gV", "`[v`]", opts)
keymap("n", ";", ":", { noremap = true })
-- Bubble single lines with vim-unimpaired
keymap("n", "<C-Up>", "[e", opts)
keymap("n", "<C-Down>", "]e", opts)
-- Bubble multiple lines with vim-unimpaired
keymap("v", "<C-Up>", "[egv", opts)
keymap("v", "<C-Down>", "]egv", opts)

View File

@ -0,0 +1,32 @@
require("nvim-lsp-installer").setup({
ensure_installed = {
"bashls",
"cmake",
"cssls",
"dockerls",
"eslint",
"graphql",
"html",
"jsonls",
"tsserver",
"ltex",
"sumneko_lua",
"marksman",
"pylsp",
"rust_analyzer",
"stylelint_lsp",
"vimls",
"lemminx",
"yamlls",
"zls",
},
ui = {
check_outdated_servers_on_open = false,
icons = {
server_installed = "",
server_pending = "",
server_uninstalled = "",
},
},
})

View File

@ -0,0 +1,87 @@
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
PACKER_BOOTSTRAP = fn.system {
"git",
"clone",
"--depth",
"1",
"https://github.com/wbthomason/packer.nvim",
install_path,
}
print "Installing packer close and reopen Neovim..."
vim.cmd [[packadd packer.nvim]]
end
vim.cmd [[
augroup packer_user_config
autocmd!
autocmd BufWritePost plugins.lua source <afile> | PackerSync
augroup end
]]
local status_ok, packer = pcall(require, "packer")
if not status_ok then
return
end
packer.init {
display = {
open_fn = function()
return require("packer.util").float { border = "rounded" }
end,
},
}
return packer.startup(function(use)
-- Utilities
use { "wbthomason/packer.nvim", opt = true }
use { "mbbill/undotree" }
use { "nvim-lua/plenary.nvim" }
use {
"nvim-treesitter/nvim-treesitter",
event = "BufEnter",
run = ":TSUpdate",
config = [[require('config.treesitter')]]
}
use { "tpope/vim-fugitive", event = "User InGitRepo" }
-- Editing
use { "andymass/vim-matchup", after = "nvim-treesitter" }
use { "godlygeek/tabular" }
use { "JoosepAlviste/nvim-ts-context-commentstring", after = "nvim-treesitter" }
use { "kana/vim-textobj-user" }
use { "mg979/vim-visual-multi", branch = "master" }
use { "nvim-treesitter/nvim-treesitter-context", after = "nvim-treesitter" }
use { "nvim-treesitter/nvim-treesitter-textobjects", after = "nvim-treesitter" }
use { "p00f/nvim-ts-rainbow", after = "nvim-treesitter" }
use { "terryma/vim-expand-region" }
use { "tommcdo/vim-exchange", event = "VimEnter" }
use { "tpope/vim-abolish" }
use { "tpope/vim-commentary", event = "VimEnter" }
use { "tpope/vim-repeat", event = "VimEnter" }
use { "tpope/vim-surround", event = "VimEnter" }
use { "windwp/nvim-autopairs", after = "nvim-treesitter" }
use { "windwp/nvim-ts-autotag", after = "nvim-treesitter" }
-- UI
use { "junegunn/goyo.vim" }
use { "junegunn/limelight.vim" }
use { "markonm/traces.vim" }
-- Searching
use { "nvim-telescope/telescope.nvim", after = "nvim-treesitter", config = [[require('config.telescope')]] }
use { "cljoly/telescope-repo.nvim", requires = "telescope.nvim" }
use { "dyng/ctrlsf.vim" }
-- LSP
use { "neovim/nvim-lspconfig" }
use { "williamboman/nvim-lsp-installer", config = [[require('config.lsp')]] }
use { "jose-elias-alvarez/null-ls.nvim" }
if PACKER_BOOTSTRAP then
require("packer").sync()
end
end)

View File

@ -0,0 +1,46 @@
local status_ok, telescope = pcall(require, "telescope")
if not status_ok then
return
end
local actions = require("telescope.actions")
telescope.setup({
defaults = {
file_ignore_patterns = { ".git/", "node_modules" },
},
mappings = {
i = {
["<Down>"] = actions.cycle_history_next,
["<Up>"] = actions.cycle_history_prev,
["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous,
},
},
extensions = {
repo = {
list = {
fd_opts = {
"--no-ignore-vcs",
},
search_dirs = {
"~/projects",
"~/repos",
"~/workspace",
},
},
},
},
})
telescope.load_extension("repo")
local keymap = vim.keymap.set
local opts = { noremap = true, silent = true }
keymap("n", "<Leader>ff", "<cmd>Telescope find_files<cr>", opts)
keymap("n", "<Leader>fg", "<cmd>Telescope live_grep<cr>", opts)
keymap("n", "<Leader>fb", "<cmd>Telescope buffers<cr>", opts)
keymap("n", "<Leader>fh", "<cmd>Telescope help_tags<cr>", opts)
keymap("n", "<Leader>fr", "<cmd>Telescope repo list<cr>", opts)

View File

@ -0,0 +1,75 @@
require("nvim-treesitter.configs").setup({
ensure_installed = {
"bash",
"c",
"cmake",
"cpp",
"css",
"dockerfile",
"glsl",
"graphql",
"haskell",
"http",
"html",
"java",
"javascript",
"jsdoc",
"json",
"json5",
"latex",
"lua",
"markdown",
"ninja",
"nix",
"org",
"perl",
"php",
"pug",
"python",
"regex",
"rst",
"ruby",
"rust",
"scala",
"scss",
"toml",
"tsx",
"typescript",
"vim",
"yaml",
"zig"
},
ignore_install = {},
highlight = {
enable = true,
disable = {},
},
indent = { enable = true },
incremental_selection = {
enable = true,
keymaps = {
init_selection = "gnn",
node_incremental = "grn",
scope_incremental = "grc",
node_decremental = "grm",
},
},
-- Extensions
autotag = { enable = true },
context_commentstring = { enable = true },
matchup = { enable = true },
rainbow = { enable = true },
textobjects = {
select = {
enable = true,
keymaps = {
["af"] = "@function.outer",
["if"] = "@function.inner",
},
},
},
})
vim.opt.foldmethod = "expr"
vim.opt.foldexpr = "nvim_treesitter#foldexpr()"