aboutsummaryrefslogtreecommitdiff
path: root/conf.d/04editor.fish
blob: e98a8823a8e4131ae2cf9d28e05230698f42e3b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
if status is-interactive

  # Text editors to look for by order of preference
  set -f editors 'nvim' 'vim' 'vi' 'micro' 'nano'
  set -f found_editor (find_prog $editors)

  if test -n "$found_editor"

    switch $found_editor
      case 'nvim'
        alias vi nvim
        alias vim nvim
        alias vimdiff 'nvim -d'
        alias vicfg 'nvim ~/.config/nvim/init.lua'
        alias vipcfg 'nvim ~/.config/nvim/plugins'
        set -x MANPAGER 'nvim +Man!'
      case 'vim'
        alias vi vim
        alias nvim vim
        alias vicfg 'vim ~/.config/vim/init.vim'
        alias vipcfg 'vim ~/.config/vim/plugins'
        set -x MANPAGER 'vim +MANPAGER --not-a-term -'
      case 'vi'
        alias vim vi
        alias nvim vi
    end

    alias e $found_editor

    # If $EDITOR is unset, set it
    if test -z "$EDITOR"
      set -x EDITOR $found_editor
    end

  end

  alias_if nano edit
  alias_if micro edit

  alias cfg 'e ~/.config/fish/config.fish'

  if not test -z "$WAYLAND_DISPLAY"; and not test -z "$DISPLAY"; and not fish_is_root_user

    # Graphical text editors to look for by order of preference
    set -f xeditors 'neovide' 'gvim'
    set -f found_xeditor (find_prog $xeditors)

    if test -n "$found_xeditor"

      switch $found_xeditor
        case 'neovide'
          alias xvi neovide
          alias gvim neovide
        case 'gvim'
          alias xvi gvim
      end

      alias xe $found_xeditor

    end

  end

  alias_if mousepad xedit

  # Pagers to look for by order of preference
  set -f pagers 'moor' 'most' 'less' 'more'
  set -f found_pager (find_prog $pagers)

  if test -n "$found_pager"

    switch $found_pager
      case 'moor'
        set -x MOOR '--colors=auto --no-linenumbers'
        alias less 'moor'
        alias most 'moor'
        alias more 'moor'
        alias pager 'moor'
        alias rawpager 'moor'
      case 'less'
        if test -z "$LESSHISTFILE"
          set -x LESSHISTFILE '-'
        end
        alias most 'less'
        alias more 'less'
        alias pager 'less'
        alias rawpager 'less -r'
      case 'most'
        if test -z "$MOST_INITFILE"
          set -x MOST_INITFILE "$HOME/.config/most/config"
        end
        alias more 'most'
        alias less 'most'
        alias pager 'most'
        alias rawpager 'most'
      case 'more'
        alias less 'more'
        alias most 'more'
        alias pager 'more'
        alias rawpager 'more'
    end

    # If $PAGER is unset, set it
    if test -z "$PAGER"
      set -x PAGER $found_pager
    end

  end

end