diff options
-rw-r--r-- | Makefile | 3 | ||||
-rwxr-xr-x | bin/install.sh | 30 | ||||
-rwxr-xr-x | profile.sh (renamed from bin/init/load-settings.sh) | 9 | ||||
-rw-r--r-- | vim/init/keymaps.vim | 4 | ||||
-rw-r--r-- | vim/lua/configs/conform.lua | 2 | ||||
-rw-r--r-- | vim/lua/mappings.lua | 8 | ||||
-rw-r--r-- | vim/lua/options.lua | 2 | ||||
-rw-r--r-- | vim/lua/plugins/init.lua | 1 |
8 files changed, 34 insertions, 25 deletions
@@ -1,6 +1,9 @@ | |||
1 | .ONESHELL: | 1 | .ONESHELL: |
2 | .PHONY: * | 2 | .PHONY: * |
3 | 3 | ||
4 | help: | ||
5 | @echo Use make all for git tig vim settings | ||
6 | |||
4 | all: git tig vim gpg | 7 | all: git tig vim gpg |
5 | mkdir -p ~/git | 8 | mkdir -p ~/git |
6 | 9 | ||
diff --git a/bin/install.sh b/bin/install.sh index cfc13d3..94f23e5 100755 --- a/bin/install.sh +++ b/bin/install.sh | |||
@@ -7,24 +7,36 @@ SETTING_DIR=${SETTING_DIR:-~/helper} | |||
7 | REPO=${REPO:-typebrook/helper} | 7 | REPO=${REPO:-typebrook/helper} |
8 | REMOTE=${REMOTE:-https://github.com/${REPO}.git} | 8 | REMOTE=${REMOTE:-https://github.com/${REPO}.git} |
9 | BRANCH=${BRANCH:-dev} | 9 | BRANCH=${BRANCH:-dev} |
10 | RCFILE=${RCFILE:-~/.$(basename $SHELL)rc} | 10 | COMMENT_IN_RCFILE="# $REPO: source custom shell settings" |
11 | PROFILE=profile.sh | ||
11 | 12 | ||
13 | case "$(basename $SHELL)" in | ||
14 | bash) RCFILE=~/.bashrc | ||
15 | ;; | ||
16 | zsh) RCFILE=~/.config/zsh/.zshrc | ||
17 | ;; | ||
18 | *) echo Current shell is not bash or zsh; exit 1; | ||
19 | ;; | ||
20 | esac | ||
21 | |||
22 | # If ~/helper doesn't exist, do git clone | ||
12 | if [ ! -d $SETTING_DIR ]; then | 23 | if [ ! -d $SETTING_DIR ]; then |
13 | git clone --depth=1 --branch "$BRANCH" "$REMOTE" "$SETTING_DIR" || { | 24 | git clone --depth=1 --branch "$BRANCH" "$REMOTE" "$SETTING_DIR" || { |
14 | error "git clone of helper repo failed" | 25 | error "git clone of helper repo failed" |
15 | exit 1 | 26 | exit 1 |
16 | } | 27 | } |
17 | fi | 28 | fi |
18 | 29 | ||
19 | # Write initial commands into .bashrc or .zshrc | 30 | # Write initial commands into .bashrc or .zshrc |
20 | sed -i'.bak' "\^# $REPO^, /^$/ d" $RCFILE | 31 | sed -i "\^$COMMENT_IN_RCFILE^, /^$/ d" $RCFILE |
21 | cat >>$RCFILE <<EOF | 32 | cat >>$RCFILE <<EOF |
22 | 33 | ||
23 | # $REPO | 34 | $COMMENT_IN_RCFILE |
24 | export SETTING_DIR=$SETTING_DIR | 35 | export SETTING_DIR=$SETTING_DIR |
25 | source \$SETTING_DIR/bin/init/load-settings.sh | 36 | source \$SETTING_DIR/$PROFILE |
37 | |||
26 | EOF | 38 | EOF |
27 | 39 | ||
40 | echo Add profile into $RCFILE | ||
28 | cd "$SETTING_DIR" || exit 1 | 41 | cd "$SETTING_DIR" || exit 1 |
29 | make | 42 | make |
30 | EOF | ||
diff --git a/bin/init/load-settings.sh b/profile.sh index cf1273a..9ebe755 100755 --- a/bin/init/load-settings.sh +++ b/profile.sh | |||
@@ -9,15 +9,12 @@ export XDG_STATE_HOME=~/.local/share/ | |||
9 | export MAIL=$HOME/Maildir | 9 | export MAIL=$HOME/Maildir |
10 | if which nvim &>/dev/null; then | 10 | if which nvim &>/dev/null; then |
11 | export EDITOR=nvim | 11 | export EDITOR=nvim |
12 | export VISUAL=nvim | ||
13 | export TIG_EDITOR=nvim | ||
14 | export GIT_EDITOR=nvim | ||
15 | else | 12 | else |
16 | export EDITOR=vim | 13 | export EDITOR=vim |
17 | export VISUAL=vim | ||
18 | export TIG_EDITOR=vim | ||
19 | export GIT_EDITOR=vim | ||
20 | fi | 14 | fi |
15 | export VISUAL=$EDITOR | ||
16 | export TIG_EDITOR=$EDITOR | ||
17 | export GIT_EDITOR=$EDITOR | ||
21 | 18 | ||
22 | # Get current shell | 19 | # Get current shell |
23 | shell=$(</proc/$$/cmdline sed -E 's/(.)-.+$/\1/' | tr -d '[\0\-]') | 20 | shell=$(</proc/$$/cmdline sed -E 's/(.)-.+$/\1/' | tr -d '[\0\-]') |
diff --git a/vim/init/keymaps.vim b/vim/init/keymaps.vim index 14d813b..f789ceb 100644 --- a/vim/init/keymaps.vim +++ b/vim/init/keymaps.vim | |||
@@ -78,9 +78,9 @@ vnoremap <leader>, :terminal<CR> | |||
78 | map <leader>pp :setlocal paste!<cr> | 78 | map <leader>pp :setlocal paste!<cr> |
79 | 79 | ||
80 | " Switch CDW to root git directory | 80 | " Switch CDW to root git directory |
81 | nnoremap <Leader>cg :execute 'cd' fnameescape(fnamemodify(finddir('.git', escape(expand('%:p:h'), ' ') . ';'), ':h'))<CR>:pwd<CR> | 81 | nnoremap cdg :execute 'cd' fnameescape(fnamemodify(finddir('.git', escape(expand('%:p:h'), ' ') . ';'), ':h'))<CR>:pwd<CR> |
82 | " Switch CWD to the directory of the open buffer | 82 | " Switch CWD to the directory of the open buffer |
83 | map <leader>cd :cd %:p:h<cr>:pwd<cr> | 83 | nnoremap cd :cd %:p:h<cr>:pwd<cr> |
84 | 84 | ||
85 | " Move one line up and down | 85 | " Move one line up and down |
86 | nnoremap <C-j> ddp | 86 | nnoremap <C-j> ddp |
diff --git a/vim/lua/configs/conform.lua b/vim/lua/configs/conform.lua index 1b6683b..411336e 100644 --- a/vim/lua/configs/conform.lua +++ b/vim/lua/configs/conform.lua | |||
@@ -5,6 +5,8 @@ local options = { | |||
5 | html = { "prettier" }, | 5 | html = { "prettier" }, |
6 | markdown = { "prettier" }, | 6 | markdown = { "prettier" }, |
7 | sh = {"shfmt"}, | 7 | sh = {"shfmt"}, |
8 | bash = {"shfmt"}, | ||
9 | zsh = {"shfmt"}, | ||
8 | }, | 10 | }, |
9 | 11 | ||
10 | -- format_on_save = { | 12 | -- format_on_save = { |
diff --git a/vim/lua/mappings.lua b/vim/lua/mappings.lua index fd58297..401c0f8 100644 --- a/vim/lua/mappings.lua +++ b/vim/lua/mappings.lua | |||
@@ -24,14 +24,6 @@ end, { desc = "format files" }) | |||
24 | vim.keymap.set("n", "<leader>ds", vim.diagnostic.setloclist, { desc = "lsp diagnostic loclist" }) | 24 | vim.keymap.set("n", "<leader>ds", vim.diagnostic.setloclist, { desc = "lsp diagnostic loclist" }) |
25 | 25 | ||
26 | -- tabufline | 26 | -- tabufline |
27 | vim.keymap.set("n", "<tab>", function() | ||
28 | require("nvchad.tabufline").next() | ||
29 | end, { desc = "buffer goto next" }) | ||
30 | |||
31 | vim.keymap.set("n", "<S-tab>", function() | ||
32 | require("nvchad.tabufline").prev() | ||
33 | end, { desc = "buffer goto prev" }) | ||
34 | |||
35 | vim.keymap.set("n", "<leader>x", function() | 27 | vim.keymap.set("n", "<leader>x", function() |
36 | require("nvchad.tabufline").close_buffer() | 28 | require("nvchad.tabufline").close_buffer() |
37 | end, { desc = "buffer close" }) | 29 | end, { desc = "buffer close" }) |
diff --git a/vim/lua/options.lua b/vim/lua/options.lua index f9e6e7e..c16ae64 100644 --- a/vim/lua/options.lua +++ b/vim/lua/options.lua | |||
@@ -18,3 +18,5 @@ o.completeopt = 'menuone,noselect' | |||
18 | 18 | ||
19 | -- NOTE: You should make sure your terminal supports this | 19 | -- NOTE: You should make sure your terminal supports this |
20 | o.termguicolors = true | 20 | o.termguicolors = true |
21 | |||
22 | o.whichwrap = "b,s" | ||
diff --git a/vim/lua/plugins/init.lua b/vim/lua/plugins/init.lua index 12f74f8..8c49369 100644 --- a/vim/lua/plugins/init.lua +++ b/vim/lua/plugins/init.lua | |||
@@ -30,6 +30,7 @@ return { | |||
30 | 30 | ||
31 | { | 31 | { |
32 | "stevearc/conform.nvim", | 32 | "stevearc/conform.nvim", |
33 | lazy = false, | ||
33 | -- event = 'BufWritePre', -- uncomment for format on save | 34 | -- event = 'BufWritePre', -- uncomment for format on save |
34 | config = function() | 35 | config = function() |
35 | require "configs.conform" | 36 | require "configs.conform" |