~misterio/nix-config

cac62b371c11ca944188876200155494d9f8ac5e — Gabriel Fontes 2 months ago 0f7f82e
home/nvim: cleanup plugins
5 files changed, 73 insertions(+), 203 deletions(-)

M flake.nix
M home/misterio/cli/nvim/default.nix
D home/misterio/cli/nvim/syntax.nix
M home/misterio/cli/nvim/theme.nix
D home/misterio/cli/nvim/ui.nix
M flake.nix => flake.nix +1 -2
@@ 156,8 156,7 @@
            "laptop"
            "games"
          ];
          colorscheme = "paraiso";
          wallpaper = "plains-gold-field";
          colorscheme = "spaceduck";
        };
        # Secondary Desktop
        "misterio@maia" = mkHome {

M home/misterio/cli/nvim/default.nix => home/misterio/cli/nvim/default.nix +68 -31
@@ 1,10 1,7 @@
{ config, pkgs, ... }:

let
  vimThemeFromScheme = import ./theme.nix { inherit pkgs; };
in
{
  imports = [ ./ui.nix ./lsp.nix ./syntax.nix ];
  imports = [ ./lsp.nix ];

  home = {
    sessionVariables.EDITOR = "nvim";


@@ 15,22 12,19 @@ in

  programs.neovim = {
    enable = true;

    extraConfig = /* vim */ ''
      "Use truecolor
      set termguicolors

      "Reload automatically
      set autoread
      au CursorHold,CursorHoldI * checktime

      "Set fold level to highest in file
      "so everything starts out unfolded at just the right level
      autocmd BufWinEnter * let &foldlevel = max(map(range(1, line('$')), 'foldlevel(v:val)'))

      "Tabs
      set ts=4 sts=4 sw=4 "4 char-wide tab
      autocmd FileType json,html,htmldjango,hamlet,nix,scss,typescript,php,haskell,terraform setlocal ts=2 sts=2 sw=2 "2 char-wide overrides
      set expandtab "Use spaces
      autocmd FileType json,html,htmldjango,hamlet,nix,scss,typescript,php,haskell,terraform setlocal ts=2 sts=2 sw=2 "2 char-wide overrides

      "Set tera to use htmldjango syntax
      autocmd BufRead,BufNewFile *.tera setfiletype htmldjango


@@ 38,9 32,6 @@ in
      "Options when composing mutt mail
      autocmd FileType mail set noautoindent wrapmargin=0 textwidth=0 linebreak wrap formatoptions +=w

      "Clipboard
      set clipboard=unnamedplus

      "Fix nvim size according to terminal
      "(https://github.com/neovim/neovim/issues/11330)
      autocmd VimEnter * silent exec "!kill -s SIGWINCH" getpid()


@@ 55,39 46,85 @@ in
      "Bind make"
      nmap <space>m <cmd>make<cr>
    '';

    plugins = with pkgs.vimPlugins; [
      plenary-nvim
      editorconfig-vim
      vim-fugitive
      vim-matchup
      vim-surround
      # Syntaxes
      rust-vim
      dart-vim-plugin
      plantuml-syntax
      vim-markdown
      vim-nix
      vim-toml
      vim-syntax-shakespeare
      gemini-vim-syntax
      kotlin-vim
      haskell-vim
      mermaid-vim
      pgsql-vim

      # UI
      vim-illuminate
      vim-numbertoggle
      {
        plugin = better-escape-nvim;
        plugin = undotree;
        config = /* vim */ ''
          lua require('better_escape').setup()
          let g:undotree_SetFocusWhenToggle = 1
          nmap <C-n> :UndotreeToggle<cr>
        '';
      }
      {
        plugin = nvim-autopairs;
        plugin = which-key-nvim;
        config = /* vim */ ''
          lua require('nvim-autopairs').setup{}
          lua require('which-key').setup{}
        '';
      }
      {
        plugin = vimThemeFromScheme { scheme = config.colorscheme; };
        plugin = range-highlight-nvim;
        config = /* vim */ ''
          colorscheme nix-${config.colorscheme.slug}
          lua require('range-highlight').setup{}
        '';
      }
      {
        plugin = indent-blankline-nvim;
        config = /* vim */ ''
          lua require('indent_blankline').setup{char_highlight_list={'IndentBlankLine'}}
        '';
      }
      {
        plugin = nvim-web-devicons;
        config = /* vim */ ''
          lua require('nvim-web-devicons').setup{}
        '';
      }
      {
        plugin = vim-medieval;
        config = let
          psqlf = "${pkgs.writeShellScriptBin "psqlf" /* sh */ ''
            psql -f "$@"
          ''}/bin/psqlf";
        in /* vim */ ''
          nmap Z <Plug>(medieval-eval)
          let g:medieval_langs = ['haskell=runghc', 'sql=${psqlf}', 'sh']
        plugin = gitsigns-nvim;
        config = /* vim */ ''
          lua require('gitsigns').setup()
        '';
      }
      {
        plugin = nvim-colorizer-lua;
        config = /* vim */ ''
          set termguicolors
          lua require('colorizer').setup()
        '';
      }

      # Misc
      editorconfig-vim
      vim-surround
      vim-fugitive
      {
        plugin = nvim-autopairs;
        config = /* vim */ ''
          lua require('nvim-autopairs').setup{}
        '';
      }
      {
        plugin = pkgs.writeTextDir "colors/nix-${config.colorscheme.slug}.vim"
          (import ./theme.nix config.colorscheme);
        config = /* vim */ ''
          colorscheme nix-${config.colorscheme.slug}
        '';
      }
    ];

D home/misterio/cli/nvim/syntax.nix => home/misterio/cli/nvim/syntax.nix +0 -33
@@ 1,33 0,0 @@
{ pkgs, ... }:
let
  inherit (builtins) attrValues removeAttrs;
in
{
  programs.neovim.plugins = with pkgs.vimPlugins; [
    rust-vim
    dart-vim-plugin
    plantuml-syntax
    vim-markdown
    vim-nix
    vim-toml
    vim-syntax-shakespeare
    gemini-vim-syntax
    kotlin-vim
    haskell-vim
    mermaid-vim
    {
      plugin = pgsql-vim;
      config = ''
        let g:sql_type_default = 'pgsql'
      '';
    }
    {
      plugin = nvim-treesitter.withPlugins (p: attrValues (removeAttrs p [ "tree-sitter-nix" ]));
      config = /* vim */ ''
        lua require('nvim-treesitter.configs').setup{highlight={enable=true}}
        set foldmethod=expr
        set foldexpr=nvim_treesitter#foldexpr()
      '';
    }
  ];
}

M home/misterio/cli/nvim/theme.nix => home/misterio/cli/nvim/theme.nix +4 -7
@@ 1,10 1,7 @@
{ pkgs }: { scheme }:
let
  c = scheme.colors;
  inherit (scheme) slug;
in
pkgs.writeTextDir "colors/nix-${slug}.vim" /* vim */ ''
  let g:colors_name="nix-${slug}"
scheme:
let c = scheme.colors;
in /* vim */ ''
  let g:colors_name="nix-${scheme.slug}"

  set termguicolors


D home/misterio/cli/nvim/ui.nix => home/misterio/cli/nvim/ui.nix +0 -130
@@ 1,130 0,0 @@
{ pkgs, ... }: {
  programs.neovim.plugins = with pkgs.vimPlugins; [
    vim-illuminate
    vim-numbertoggle
    {
      plugin = undotree;
      config = /* vim */ ''
        lua require('nvim-tree').setup{ renderer = { group_empty= true } }
        let g:undotree_SetFocusWhenToggle = 1
        nmap <C-n> :UndotreeToggle<cr>
      '';
    }
    undotree
    {
      plugin = telescope-nvim;
      config = /* vim */ ''
        nnoremap <space>t <cmd>Telescope find_files<cr>
        nnoremap <space>g <cmd>Telescope live_grep<cr>

        lua << EOF
        local actions = require('telescope.actions')
        local action_state = require('telescope.actions.state')
        local telescope_custom_actions = {}

        function telescope_custom_actions._multiopen(prompt_bufnr, open_cmd)
          local picker = action_state.get_current_picker(prompt_bufnr)
          local selected_entry = action_state.get_selected_entry()
          local num_selections = #picker:get_multi_selection()
          if not num_selections or num_selections <= 1 then
              actions.add_selection(prompt_bufnr)
          end
          actions.send_selected_to_qflist(prompt_bufnr)
          vim.cmd("cfdo " .. open_cmd)
        end
        function telescope_custom_actions.multi_selection_open(prompt_bufnr)
          telescope_custom_actions._multiopen(prompt_bufnr, "edit")
        end


        require('telescope').setup {
          defaults = {
            mappings = {
              i = {
                ['<C-j>'] = actions.move_selection_next,
                ['<C-k>'] = actions.move_selection_previous,
                ['<tab>'] = actions.toggle_selection + actions.move_selection_next,
                ['<s-tab>'] = actions.toggle_selection + actions.move_selection_previous,
                ['<cr>'] = telescope_custom_actions.multi_selection_open
              },
              n = {
                ['<tab>'] = actions.toggle_selection + actions.move_selection_next,
                ['<s-tab>'] = actions.toggle_selection + actions.move_selection_previous,
                ['<cr>'] = telescope_custom_actions.multi_selection_open
              }
            },
          }
        }
        EOF
      '';
    }
    {
      plugin = which-key-nvim;
      config = /* vim */ ''
        lua require('which-key').setup{}
      '';
    }
    {
      plugin = range-highlight-nvim;
      config = /* vim */ ''
        lua require('range-highlight').setup{}
      '';
    }
    {
      plugin = indent-blankline-nvim;
      config = /* vim */ ''
        lua require('indent_blankline').setup{char_highlight_list={'IndentBlankLine'}}
      '';
    }
    {
      plugin = nvim-web-devicons;
      config = /* vim */ ''
        lua require('nvim-web-devicons').setup{}
      '';
    }
    {
      plugin = gitsigns-nvim;
      config = /* vim */ ''
        lua require('gitsigns').setup()
      '';
    }
    {
      plugin = nvim-colorizer-lua;
      config = /* vim */ ''
        set termguicolors
        lua require('colorizer').setup()
      '';
    }

    {
      plugin = barbar-nvim;
      config = /* vim */ ''
        let bufferline = get(g:, 'bufferline', {})
        let bufferline.animation = v:true
        nmap <C-h>   :BufferPrevious<CR>
        nmap <C-l>   :BufferNext<CR>
        nmap <C-q>   :BufferClose<CR>
        nmap <C-a>   :BufferPick<CR>
        nmap <C-M-h> :BufferMovePrevious<CR>
        nmap <C-M-l> :BufferMoveNext<CR>
        nmap <M-1>   :BufferGoto 1<CR>
        nmap <M-2>   :BufferGoto 2<CR>
        nmap <M-3>   :BufferGoto 3<CR>
        nmap <M-4>   :BufferGoto 4<CR>
        nmap <M-5>   :BufferGoto 5<CR>
        nmap <M-6>   :BufferGoto 6<CR>
        nmap <M-7>   :BufferGoto 7<CR>
        nmap <M-8>   :BufferGoto 8<CR>
        nmap <M-9>   :BufferGoto 9<CR>
      '';
    }

    {
      plugin = nvim-tree-lua;
      config = /* vim */ ''
        lua require('nvim-tree').setup{}
        nmap <C-p> :NvimTreeToggle<CR>
      '';
    }
  ];
}