diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua new file mode 100644 index 0000000..d205050 --- /dev/null +++ b/dotfiles/neovim/init.lua @@ -0,0 +1,14 @@ +local cmd = vim.cmd -- to execute Vim commands e.g. cmd('pwd') +local fn = vim.fn -- to call Vim functions e.g. fn.bufnr() +local g = vim.g -- a table to access global variables +local opt = vim.opt -- to set options + +-- Basic options +opt.number = true -- Show line numbers +opt.relativenumber = true -- Relative line numbers + +-- Set theme +require('github-theme').setup() + +-- Import my other files +require('my.keymaps').setup() \ No newline at end of file diff --git a/dotfiles/neovim/lua/my/keymaps.lua b/dotfiles/neovim/lua/my/keymaps.lua new file mode 100644 index 0000000..f9a011f --- /dev/null +++ b/dotfiles/neovim/lua/my/keymaps.lua @@ -0,0 +1,11 @@ +local M = {} + +local function map(mode, lhs, rhs, opts) + local options = {noremap = true} + if opts then options = vim.tbl_extend('force', options, opts) end + vim.api.nvim_set_keymap(mode, lhs, rhs, options) +end + +function M.setup() + map("i", "jj", "") -- Remap Esc to +end \ No newline at end of file diff --git a/flake.lock b/flake.lock index 82bac41..4c3de21 100644 --- a/flake.lock +++ b/flake.lock @@ -48,6 +48,37 @@ "type": "github" } }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1641205782, + "narHash": "sha256-4jY7RCWUoZ9cKD8co0/4tFARpWB+57+r1bLLvXNJliY=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "b7547d3eed6f32d06102ead8991ec52ab0a4f1a7", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1638122382, + "narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "74f7e4319258e287b0f9cb95426c9853b282730b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "githubNvimTheme": { "flake": false, "locked": { @@ -132,6 +163,22 @@ "type": "github" } }, + "nixpkgs_2": { + "locked": { + "lastModified": 1642130244, + "narHash": "sha256-/5FhZkZFQCRQIRFosUQW1zmDrsNHVOJIB/+XgRPHiPU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "bc59ba15b64d0a0ee1d1764f18b4f3480d2c3e5a", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "root": { "inputs": { "agnoster": "agnoster", @@ -142,9 +189,30 @@ "nixos-unstable": "nixos-unstable", "nixpkgs": "nixpkgs", "nixpkgs-unstable": "nixpkgs-unstable", + "vim-extra-plugins": "vim-extra-plugins", "z": "z" } }, + "vim-extra-plugins": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1643552572, + "narHash": "sha256-D7VC0Fp1a7+E03D3NuZNNXO4T44UWOVNBDK1fuKVQD4=", + "owner": "m15a", + "repo": "nixpkgs-vim-extra-plugins", + "rev": "fbc282994561119dd67bdc40566a67a5584ac6b2", + "type": "github" + }, + "original": { + "owner": "m15a", + "repo": "nixpkgs-vim-extra-plugins", + "type": "github" + } + }, "z": { "flake": false, "locked": { diff --git a/flake.nix b/flake.nix index e892a55..73d518d 100644 --- a/flake.nix +++ b/flake.nix @@ -23,6 +23,8 @@ githubNvimTheme.url = "github:projekt0n/github-nvim-theme"; githubNvimTheme.flake = false; + + vim-extra-plugins.url = "github:m15a/nixpkgs-vim-extra-plugins"; }; outputs = inputs@{ self, nixpkgs, home-manager, ... }: diff --git a/modules/applications/misc.nix b/modules/applications/misc.nix index a3fcc04..72e7253 100644 --- a/modules/applications/misc.nix +++ b/modules/applications/misc.nix @@ -34,7 +34,7 @@ # vscodium vscode vim - neovim + my-neovim # emacs # chat apps diff --git a/modules/applications/neovim.nix b/modules/applications/neovim.nix new file mode 100644 index 0000000..5bec22a --- /dev/null +++ b/modules/applications/neovim.nix @@ -0,0 +1,14 @@ +{ wrapNeovim, neovim, tree-sitter, config-nvim, vimPlugins, vimExtraPlugins }: + +wrapNeovim neovim { + configure = { + customRC = '' + let g:disable_paq = v:true + luafile ${config-nvim}/init.lua + ''; + + packages.default = with vimExtraPlugins; { + start = [ config-nvim vimExtraPlugins.github-nvim-theme ]; + }; + }; +} diff --git a/modules/overlays/default.nix b/modules/overlays/default.nix index 925f1e5..3e6a0a6 100644 --- a/modules/overlays/default.nix +++ b/modules/overlays/default.nix @@ -1 +1,7 @@ -{ pkgs, ... }: { nixpkgs.overlays = [ (import ./tweakSources.nix) ]; } +{ pkgs, ... }: { + nixpkgs.overlays = [ + (import ./tweakSources.nix) + # neovim with my own config baked in + (import ./neovim.nix) + ]; +} diff --git a/modules/overlays/flakes.nix b/modules/overlays/flakes.nix index d56bd13..1a1b384 100644 --- a/modules/overlays/flakes.nix +++ b/modules/overlays/flakes.nix @@ -1,9 +1,10 @@ { system }: { home-manager, nixpkgs, nixpkgs-unstable, nixos-unstable, easy-purescript-nix -, easy-dhall-nix, z, agnoster, githubNvimTheme, ... }: +, easy-dhall-nix, z, agnoster, githubNvimTheme, vim-extra-plugins, ... }: ({ pkgs, ... }: { nix.registry.nixpkgs.flake = nixpkgs; nixpkgs.overlays = [ + vim-extra-plugins.overlay (self: super: { # inherit nixos-unstable; unstable = import nixpkgs-unstable { diff --git a/modules/overlays/neovim.nix b/modules/overlays/neovim.nix new file mode 100644 index 0000000..556eb78 --- /dev/null +++ b/modules/overlays/neovim.nix @@ -0,0 +1,14 @@ +final: prev: + +let + config-nvim = final.vimUtils.buildVimPluginFrom2Nix { + name = "config-nvim"; + src = ../../dotfiles/neovim; + }; + +in { + my-neovim = final.callPackage ../applications/neovim.nix { + neovim = final.neovim-nightly; + inherit config-nvim; + }; +} diff --git a/oldVimConfig.vim b/oldVimConfig.vim new file mode 100644 index 0000000..87c9071 --- /dev/null +++ b/oldVimConfig.vim @@ -0,0 +1,53 @@ +" Rebind esc to pressing j twice +:imap jj + +" Indentation stuff +filetype plugin indent on +set tabstop=2 +set shiftwidth=2 +set expandtab + +" Line numbers +:set relativenumber +:set rnu + + +" Plugins +call plug#begin('~/.vim/plugged') + +Plug 'lervag/vimtex' + +" Autocompletion engine +Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } + +" A Vim Plugin for Lively Previewing LaTeX PDF Output +Plug 'xuhdev/vim-latex-live-preview', { 'for': 'tex' } + +Plug 'jiangmiao/auto-pairs' + +call plug#end() + +" ========== Latext setup +" Activate deoplete +let g:deoplete#enable_at_startup = 1 + +" Minimum character length needed to activate auto-completion. +call deoplete#custom#option('min_pattern_length', 1) + +" use fuzzy matcher +call deoplete#custom#source('_', 'matchers', ['matcher_full_fuzzy']) + +" Latex autocompletion +call deoplete#custom#var('omni', 'input_patterns', { + \ 'tex': g:vimtex#re#deoplete + \}) + +let g:latex_view_general_viewer = "zathura" +let g:vimtex_view_method = "zathura" + +au FileType tex let b:AutoPairs = AutoPairsDefine({'$' : '$'}, []) + +let g:vimtex_compiler_progname = 'nvr' + +" deoplete tab-complete +inoremap pumvisible() ? "\" : "\"