From c5c8719dc7271b34c3a7f2f49d9d198490a73f96 Mon Sep 17 00:00:00 2001 From: Sean Buckley Date: Tue, 3 Oct 2023 12:27:34 -0400 Subject: [PATCH] add lunarvim --- modules/vim/default.nix | 51 +++++++++------------------ modules/vim/init.lua | 23 ++++++++++--- modules/vim/init.vim | 76 ----------------------------------------- pkgs/lunarvim.nix | 28 +++++++++++++++ 4 files changed, 64 insertions(+), 114 deletions(-) delete mode 100644 modules/vim/init.vim create mode 100644 pkgs/lunarvim.nix diff --git a/modules/vim/default.nix b/modules/vim/default.nix index 9819e2a..d17e15e 100644 --- a/modules/vim/default.nix +++ b/modules/vim/default.nix @@ -1,45 +1,28 @@ { config, lib, pkgs, ... }: { - programs.neovim = { - enable = true; - viAlias = true; - vimAlias = true; - defaultEditor = true; - configure = { - packages.sconfig.start = with pkgs.vimPlugins; [ - airline - bufferline-nvim - coc-nvim - coc-tsserver - nerdtree - nerdtree-git-plugin - vim-autoformat - vim-code-dark - vim-devicons - vim-gitgutter - vim-nix - vim-startify - vim-terraform - ] ++ - # skip syntax-highlight on nixos 23.05 - lib.optional - (vim-nerdtree-syntax-highlight.version != "2021-01-11") - (vim-nerdtree-syntax-highlight); + environment.variables.EDITOR = "vim"; - customRC = '' - source ${./init.vim} - luafile ${./init.lua} - if filereadable(expand("~/.config/nvim/init.vim")) - source ~/.config/nvim/init.vim - endif - ''; - }; - }; + environment.etc."lvim.lua".source = ./init.lua; + + environment.etc."my-settings.sh".text = '' + mkdir -p ~/.config/lvim + echo 'vim.cmd("luafile /etc/lvim.lua")' >~/.config/lvim/config.lua + ''; environment.systemPackages = with pkgs; [ + lunarvim nodePackages.prettier + (writeShellScriptBin "black" '' exec ${pkgs.python3.pkgs.black}/bin/black "$@" '') + + (writeShellScriptBin "vi" '' + exec lvim "$@" + '') + + (writeShellScriptBin "vim" '' + exec lvim "$@" + '') ]; } diff --git a/modules/vim/init.lua b/modules/vim/init.lua index cc77725..51c6eef 100644 --- a/modules/vim/init.lua +++ b/modules/vim/init.lua @@ -1,5 +1,20 @@ -require("bufferline").setup { - options = { - separator_style = "slant" - } +lvim.format_on_save = true + +vim.opt.relativenumber = true +vim.opt.shiftwidth = 4 +vim.opt.tabstop = 4 +vim.opt.whichwrap = "" + +local formatters = require "lvim.lsp.null-ls.formatters" +formatters.setup { + { exe = "nixpkgs-fmt", filetypes = { "nix" } }, + { exe = "black", filetypes = { "python" } }, + { + name = "prettier", + filetypes = { + "json", + "typescript", + "yaml" + }, + }, } diff --git a/modules/vim/init.vim b/modules/vim/init.vim deleted file mode 100644 index 13f3e85..0000000 --- a/modules/vim/init.vim +++ /dev/null @@ -1,76 +0,0 @@ -"misc -set mouse= -set encoding=utf-8 -set number relativenumber -set list listchars=tab:\|\ ,trail:- -set nowrap -set scrolloff=9 -set tabstop=4 -set shiftwidth=4 - -set termguicolors -colorscheme codedark - -nnoremap H :call CocActionAsync('doHover') - - -"configure plugins -let g:gitgutter_sign_removed = "\uE0B8" -let g:gitgutter_sign_removed_first_line = "\uE0BC" -let g:gitgutter_sign_modified_removed = '~~' -set updatetime=500 - -let g:startify_custom_header = "''" -let g:startify_custom_indices = map(range(1,100), 'string(v:val)') - -let NERDTreeMinimalUI=1 -let g:NERDTreeExtensionHighlightColor = {} -let g:NERDTreeExtensionHighlightColor['nix'] = "689FB6" -let g:NERDTreeExtensionHighlightColor['tf'] = "834F79" - -let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols = {} -let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['tf'] = "\uE69A" - - -"auto formatting -let g:formatters_python = ['black'] - -let g:formatdef_nixpkgsfmt="'nixpkgs-fmt'" -let g:formatters_nix = ['nixpkgsfmt'] - -let g:formatdef_prettier="'prettier --stdin-filepath ' . expand('%:p')" -let g:formatters_js = ['prettier'] -let g:formatters_json = ['prettier'] -let g:formatters_ts = ['prettier'] -let g:formatters_yaml = ['prettier'] - -autocmd BufWritePre * :Autoformat - - -"menus -nnoremap e :NERDTreeFocus:vertical resize 31 -nnoremap o :Startify - - -"buffers -nnoremap w :q -nnoremap q :bd -nnoremap d :bnext -nnoremap a :bprevious - -tnoremap - - -"window shortcuts -nnoremap h h -nnoremap j j -nnoremap k k -nnoremap l l - -nnoremap h -nnoremap j -nnoremap k -nnoremap l - -nnoremap v v -nnoremap s s diff --git a/pkgs/lunarvim.nix b/pkgs/lunarvim.nix new file mode 100644 index 0000000..a68ba09 --- /dev/null +++ b/pkgs/lunarvim.nix @@ -0,0 +1,28 @@ +# +# https://github.com/NixOS/nixpkgs/pull/257063 +# + +{ pkgs }: +( + ( + pkgs.callPackage + (pkgs.fetchurl { + url = "https://raw.githubusercontent.com/NixOS/nixpkgs/266e0f99a483d8e699f32b050c55981fd950de70/pkgs/by-name/lu/lunarvim/package.nix"; + sha256 = "fa44f06a517c686d181f35ee255d4e0c00c6f52473cf1a3b9586c4e511efb7d7"; + }) + { } + + ).overrideAttrs (_: { + patches = [ + ( + pkgs.fetchurl { + url = "https://github.com/LunarVim/LunarVim/commit/d187cbd03fbc8bd1b59250869e0e325518bf8798.patch"; + sha256 = "00677d3d5a4882d7ee5709e0494a5d8f7c58cea8bdcf467ce59222f9cc493366"; + } + ) + ]; + }) + +).override (_: { + python3.withPackages = _: pkgs.emptyDirectory; +})