Skip to content

Commit ea9bada

Browse files
committed
feat: setup nonest_nvim, YankAppend, and terminal integrations
1 parent 0a2e706 commit ea9bada

File tree

8 files changed

+164
-32
lines changed

8 files changed

+164
-32
lines changed

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [0.9.0] - 2020-12-20
10+
### Added
11+
- Setup nonest_nvim to prevent nested Neovim instances!
12+
- Added YankAppend function to neovim with the `gy` mapping.
13+
- Added neovim integrations with lf and lazygit.
14+
15+
### Fixed
16+
- Improved lf configs to switch to 3 or 2 panels.
17+
- Improve karabiner timing for "-" character it L_Shift.
18+
919
## [0.8.0] - 2020-12-13
1020
### Added
1121
- Switch `ytop` to `bottom` and add `curlie`.
@@ -135,7 +145,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
135145
### Added
136146
- Created basic script for proof of concept.
137147

138-
[Unreleased]: https://github.com/adamtabrams/fig/compare/0.8.0...HEAD
148+
[Unreleased]: https://github.com/adamtabrams/fig/compare/0.9.0...HEAD
149+
[0.9.0]: https://github.com/adamtabrams/fig/compare/0.8.0...0.9.0
139150
[0.8.0]: https://github.com/adamtabrams/fig/compare/0.7.6...0.8.0
140151
[0.7.6]: https://github.com/adamtabrams/fig/compare/0.7.5...0.7.6
141152
[0.7.5]: https://github.com/adamtabrams/fig/compare/0.7.4...0.7.5

home/.config/nvim/init.vim

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ set shell=/bin/zsh
105105
set history=200
106106
set mouse=a
107107
set go=a
108-
" set scrolloff=2
109108
set scrolloff=5
110109
set inccommand=split
111110
set tabstop=4 shiftwidth=4 expandtab shiftround
@@ -186,6 +185,20 @@ function! ChangeReplace(...)
186185
return ""
187186
endfunction
188187

188+
function! YankAppend(...)
189+
let motion = get(a:, 1)
190+
if a:0 == 0
191+
let motion = GetMotion()
192+
endif
193+
let regA = @a
194+
let @a = @+
195+
exe 'norm "Ay'.motion
196+
let @+ = @a
197+
let @a = regA
198+
call repeat#set(":call YankAppend('".motion."')\<CR>",-1)
199+
return ""
200+
endfunction
201+
189202
function! CleverTab()
190203
if pumvisible()
191204
return "\<c-n>"
@@ -212,6 +225,13 @@ function! AlignWithMark()
212225
return "\<c-r>=repeat(' ',col(\"'m\")-col('.'))\<CR>\<ESC>"
213226
endfunction
214227

228+
function! TempTerm(...)
229+
let command = get(a:, 1)
230+
exe "au TermClose * ++once :b#|bd!#"
231+
exe "terminal ".command
232+
return ""
233+
endfunction
234+
215235
"### Remappings ##################################
216236
"--- Hotfix --------------------------------------
217237
cnoremap 3636 <c-u>undo<CR>
@@ -239,13 +259,14 @@ nnoremap <silent> gA i<c-r>=AlignWithMark()<CR><ESC>
239259
vnoremap <silent> gA I<c-r>=AlignWithMark()<CR><ESC>
240260
241261
"--- Testing -------------------------------------
242-
nnoremap <silent> gw :w<CR>
243-
" nnoremap <silent> gN :tabnext<CR>
244-
" nnoremap <silent> gP :tabprevious<CR>
245-
nnoremap <c-d> <c-d>zz
246-
nnoremap <c-u> <c-u>zz
247-
" nnoremap n nzz
248-
" nnoremap N Nzz
262+
nnoremap <silent> gw :w<CR>
263+
nnoremap <c-m> <c-]>
264+
nnoremap <silent> gy :call YankAppend()<CR>
265+
266+
nnoremap <c-d> <c-d>zz
267+
nnoremap <c-u> <c-u>zz
268+
" nnoremap n nzz
269+
" nnoremap N Nzz
249270

250271
"--- Autocomplete --------------------------------
251272
inoremap <c-f> <c-x><c-f>
@@ -320,30 +341,31 @@ augroup END
320341

321342
"--- Leader Key ----------------------------------
322343
let mapleader = ","
344+
nnoremap <silent> <Leader>t :call TempTerm()<CR>
345+
nnoremap <silent> <Leader>g :call TempTerm("lazygit")<CR>
346+
nnoremap <silent> <Leader>l :call TempTerm("lf")<CR>
323347
324348
"--- Fzf -----------------------------------------
325349
let maplocalleader = "\<Space>"
326-
" nnoremap <LocalLeader><LocalLeader> :Lines<CR>
327-
nnoremap <LocalLeader>l :Lines<CR>
328-
nnoremap <LocalLeader>f :Files<CR>
329350
nnoremap <LocalLeader>g :GFiles<CR>
330351
nnoremap <LocalLeader>s :GFiles?<CR>
352+
nnoremap <LocalLeader><c-f> :Files<CR>
331353
nnoremap <LocalLeader>b :Buffers<CR>
332354
nnoremap <LocalLeader>w :Windows<CR>
333355
nnoremap <LocalLeader>r :Rg<CR>
334356
nnoremap <LocalLeader>h :History<CR>
335357
nnoremap <LocalLeader>m :Maps<CR>
336358
nnoremap <LocalLeader>t :Filetypes<CR>
337359
nnoremap <LocalLeader>T :set filetype=<CR>
338-
nnoremap <LocalLeader>~ :Files ~
339-
nnoremap <LocalLeader>. :Files ../
360+
nnoremap <LocalLeader>l :Lines<CR>
340361
nnoremap <LocalLeader>/ :BLines<CR>
341362
nnoremap <LocalLeader>' :Marks<CR>
342363
nnoremap <LocalLeader>: :Commands<CR>
343364
nnoremap <LocalLeader>? :Helptags<CR>
365+
nnoremap <LocalLeader>~ :Files ~
366+
nnoremap <LocalLeader>. :Files ../
344367
345368
"--- Easy Motion ---------------------------------
346369
nmap <LocalLeader><LocalLeader> <Plug>(easymotion-overwin-w)
347-
nmap <LocalLeader>A <Plug>(easymotion-jumptoanywhere)
348-
nmap <LocalLeader>F <Plug>(easymotion-bd-wl)
349-
" nmap gf <Plug>(easymotion-bd-wl)
370+
nmap <LocalLeader>a <Plug>(easymotion-jumptoanywhere)
371+
nmap <LocalLeader>f <Plug>(easymotion-bd-wl)

home/.config/zsh/alias.zsh

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ alias bc="bc -q"
66
alias vim="$EDITOR"
77
alias vi="$EDITOR"
88
alias v="$EDITOR"
9-
alias l="lfcd"
109
alias lf="lfcd"
10+
alias l="lfcd"
1111
alias lg="lazygit"
12-
alias L="lazygit"
13-
alias B="hub browse"
12+
alias g="lazygit"
13+
alias b="hub browse"
1414
alias j="jump"
1515
alias page="$PAGER --paging=always"
1616
alias bat="bat --paging=never"
@@ -31,6 +31,7 @@ alias .alias="$EDITOR $ZDOTDIR/alias.zsh"
3131
alias .env="$EDITOR $HOME/.zprofile"
3232
alias .nvim="$EDITOR $XDG_CONFIG_HOME/nvim/init.vim"
3333
alias .hist="$EDITOR $MYHIST"
34+
alias .conf="cd $XDG_CONFIG_HOME"
3435

3536
#### Functions ###################################
3637
up() { fc -e "sed -i \"\" -e \"s| | $* |\"" }
@@ -45,23 +46,34 @@ unbak() { mv "$1" $(sed "s/.bak$//" <<< "$1") }
4546

4647
mksh() { echo "#!/bin/sh" >> "$1" && chmod +x "$1" && "$EDITOR" "$1" }
4748

48-
#### Fzf #########################################
49+
#### Quick Select ################################
50+
# list quick-select commands
51+
glist() {
52+
echo "gl - goto latest dirs"
53+
echo "gr - goto repo"
54+
echo "grr - goto repo (deeper search)"
55+
echo "or - open repo in browser"
56+
echo "lr - open repo(s) in lazygit"
57+
echo "gt - goto/open from ~/temp"
58+
echo "gs - goto/open from ~/save"
59+
}
60+
4961
# go to one of the lastest dirs
5062
gl() {
51-
goto=$(cat "$DIRSTACKFILE" | fzf --reverse)
63+
goto=$(cat "$DIRSTACKFILE" | $SELECTOR)
5264
[ "$goto" ] && cd "$goto"
5365
}
5466

5567
# go to a repo
5668
gr() {
57-
repo="$(cd ~/repos && fd -d1 | fzf --reverse)"
69+
repo="$(cd ~/repos && fd -d1 | $SELECTOR)"
5870
[ "$repo" ] && cd "$HOME/repos/$repo"
5971
}
6072

6173
# go to a repo (recursive)
6274
grr() {
6375
repo="$(cd ~/repos && fd -d3 -t d -I -H "^.git$" |
64-
rev | cut -c 6- | rev | fzf --reverse)"
76+
rev | cut -c 6- | rev | $SELECTOR)"
6577
[ "$repo" ] && cd "$HOME/repos/$repo"
6678
}
6779

@@ -72,21 +84,21 @@ or() {
7284

7385
# use lazygit on one or more repos
7486
lr() {
75-
for repo in $(cd ~/repos && fd -d1 | fzf --reverse --multi); do
87+
for repo in $(cd ~/repos && fd -d1 | $SELECTOR --multi); do
7688
lazygit -p "$HOME/repos/$repo"
7789
done
7890
}
7991

8092
# go to a dir or open a file in temp
8193
gt() {
82-
sel="$HOME/temp/$(cd ~/temp && fd | fzf --reverse)"
94+
sel="$HOME/temp/$(cd ~/temp && fd | $SELECTOR)"
8395
[ -d "$sel" ] && cd "$sel"
8496
[ -f "$sel" ] && "$EDITOR" "$sel"
8597
}
8698

8799
# go to a dir or open a file in save
88100
gs() {
89-
sel="$HOME/save/$(cd ~/save && fd | fzf --reverse)"
101+
sel="$HOME/save/$(cd ~/save && fd | $SELECTOR)"
90102
[ -d "$sel" ] && cd "$sel"
91103
[ -f "$sel" ] && "$EDITOR" "$sel"
92104
}
@@ -115,7 +127,7 @@ markfile="$XDG_DATA_HOME/lf/marks"
115127
marks() { cat "$markfile" | tr ':' ' ' }
116128

117129
jump() {
118-
new_dir=$(marks | fzf --reverse | cut -f 2 -d ' ')
130+
new_dir=$(marks | $SELECTOR | cut -f 2 -d ' ')
119131
[ -d "$new_dir" ] && cd "$new_dir"
120132
}
121133

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module nonest_nvim
2+
3+
go 1.15
4+
5+
require github.com/neovim/go-client v1.1.3
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github.com/neovim/go-client v1.1.3 h1:RrjcL8ZdFNtI+w77cp0uWyHZBu2X9fHTvztipdyoZB8=
2+
github.com/neovim/go-client v1.1.3/go.mod h1:R9QUduDri8OKS78u/rAvFZmaw6pPfdb+MiKq0JYnZ+c=
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os"
6+
"os/exec"
7+
8+
"github.com/neovim/go-client/nvim"
9+
)
10+
11+
func main() {
12+
addr := os.Getenv("NVIM_LISTEN_ADDRESS")
13+
if addr == "" {
14+
editor := os.Getenv("REALEDITOR")
15+
cmd := exec.Command(editor, os.Args[1:]...)
16+
cmd.Stdin = os.Stdin
17+
cmd.Stdout = os.Stdout
18+
19+
if err := cmd.Run(); err != nil {
20+
fmt.Println(err)
21+
os.Exit(1)
22+
}
23+
os.Exit(0)
24+
}
25+
26+
fileNames := os.Args[1:]
27+
if len(fileNames) == 0 {
28+
fmt.Println("No arguments given")
29+
os.Exit(1)
30+
}
31+
32+
filePaths, err := getAbsolutePaths(fileNames...)
33+
if err != nil {
34+
fmt.Println(err)
35+
os.Exit(1)
36+
}
37+
38+
v, err := nvim.Dial(addr)
39+
if err != nil {
40+
fmt.Println(err)
41+
os.Exit(1)
42+
}
43+
44+
defer v.Close()
45+
46+
b := v.NewBatch()
47+
b.Command(":bd!")
48+
49+
for _, filePath := range filePaths {
50+
b.Command(":e " + filePath)
51+
}
52+
53+
if err := b.Execute(); err != nil {
54+
fmt.Println(err)
55+
os.Exit(1)
56+
}
57+
}
58+
59+
func getAbsolutePaths(fileNames ...string) ([]string, error) {
60+
pwd, err := os.Getwd()
61+
if err != nil {
62+
return nil, err
63+
}
64+
65+
absolutePaths := make([]string, len(fileNames))
66+
67+
for _, filePath := range fileNames {
68+
if filePath[0] != '/' {
69+
filePath = pwd + "/" + filePath
70+
}
71+
absolutePaths = append(absolutePaths, filePath)
72+
}
73+
74+
return absolutePaths, nil
75+
}
3.28 MB
Binary file not shown.

home/.zprofile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
#!/bin/zsh
22

33
#### General #####################################
4-
export EDITOR="nvim"
4+
export REALEDITOR="nvim"
5+
export EDITOR="nonest_nvim"
6+
# export EDITOR="/Users/aabrams7/repos/TEMP/neovim/build/bin/nvim"
57
export TERMINAL="/Applications/Alacritty.app/Contents/MacOS/alacritty"
68
export BROWSER="/Applications/Brave\ Browser.app/Contents/MacOS/Brave\ Browser"
9+
export SELECTOR="fzf"
710

811
export LANG="en_US.UTF-8"
912
export SHELL="zsh"
@@ -19,14 +22,15 @@ export XDG_CONFIG_HOME="$HOME/.config"
1922
export XDG_DATA_HOME="$HOME/.local/share"
2023
export XDG_CACHE_HOME="$HOME/.cache"
2124

22-
#### Path ########################################
23-
export PATH="$HOME/.local/bin:$PATH"
24-
2525
#### Files/Dirs ##################################
2626
export ZDOTDIR="$XDG_CONFIG_HOME/zsh"
2727
export MYHIST="$HOME/.local/history/histfile"
2828
export LESSHISTFILE="-"
2929

30+
#### Path ########################################
31+
export PATH="$HOME/.local/bin:$PATH"
32+
export PATH="$ZDOTDIR/nonest_nvim:$PATH"
33+
3034
#### Bat #########################################
3135
export BAT_PAGER="less -R"
3236
export BAT_CONFIG_PATH="$XDG_CONFIG_HOME/bat/bat.conf"
@@ -35,6 +39,7 @@ export BAT_CONFIG_PATH="$XDG_CONFIG_HOME/bat/bat.conf"
3539
fzf_base_command="fd --hidden --exclude .git --follow"
3640
export FZF_DEFAULT_COMMAND="$fzf_base_command --type file"
3741
export FZF_DEFAULT_OPTS="--preview='bat {} 2> /dev/null'"
42+
export FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS --reverse"
3843
export FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS --preview-window=':hidden'"
3944
export FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS --bind=ctrl-u:page-up"
4045
export FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS --bind=ctrl-d:page-down"

0 commit comments

Comments
 (0)