aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorHsieh Chin Fan <pham@topo.tw>2024-06-25 23:09:03 +0800
committerHsieh Chin Fan <pham@topo.tw>2024-06-25 23:09:03 +0800
commit59de29d5164d245dda1608f5e14cf4e1c981ad3e (patch)
tree6ac4d17b0db9b59fbc70e74efe5a06f458973904
parentba90f7398b34736f1ace01b0af90dff795fca8fb (diff)
Update
-rw-r--r--Makefile3
-rwxr-xr-xbin/install.sh30
-rwxr-xr-xprofile.sh (renamed from bin/init/load-settings.sh)9
-rw-r--r--vim/init/keymaps.vim4
-rw-r--r--vim/lua/configs/conform.lua2
-rw-r--r--vim/lua/mappings.lua8
-rw-r--r--vim/lua/options.lua2
-rw-r--r--vim/lua/plugins/init.lua1
8 files changed, 34 insertions, 25 deletions
diff --git a/Makefile b/Makefile
index e8c87a8..ba4f2b5 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,9 @@
1.ONESHELL: 1.ONESHELL:
2.PHONY: * 2.PHONY: *
3 3
4help:
5 @echo Use make all for git tig vim settings
6
4all: git tig vim gpg 7all: 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}
7REPO=${REPO:-typebrook/helper} 7REPO=${REPO:-typebrook/helper}
8REMOTE=${REMOTE:-https://github.com/${REPO}.git} 8REMOTE=${REMOTE:-https://github.com/${REPO}.git}
9BRANCH=${BRANCH:-dev} 9BRANCH=${BRANCH:-dev}
10RCFILE=${RCFILE:-~/.$(basename $SHELL)rc} 10COMMENT_IN_RCFILE="# $REPO: source custom shell settings"
11PROFILE=profile.sh
11 12
13case "$(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 ;;
20esac
21
22# If ~/helper doesn't exist, do git clone
12if [ ! -d $SETTING_DIR ]; then 23if [ ! -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 }
17fi 28fi
18 29
19# Write initial commands into .bashrc or .zshrc 30# Write initial commands into .bashrc or .zshrc
20sed -i'.bak' "\^# $REPO^, /^$/ d" $RCFILE 31sed -i "\^$COMMENT_IN_RCFILE^, /^$/ d" $RCFILE
21cat >>$RCFILE <<EOF 32cat >>$RCFILE <<EOF
22 33
23# $REPO 34$COMMENT_IN_RCFILE
24export SETTING_DIR=$SETTING_DIR 35export SETTING_DIR=$SETTING_DIR
25source \$SETTING_DIR/bin/init/load-settings.sh 36source \$SETTING_DIR/$PROFILE
37
26EOF 38EOF
27 39
40echo Add profile into $RCFILE
28cd "$SETTING_DIR" || exit 1 41cd "$SETTING_DIR" || exit 1
29make 42make
30EOF
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/
9export MAIL=$HOME/Maildir 9export MAIL=$HOME/Maildir
10if which nvim &>/dev/null; then 10if 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
15else 12else
16 export EDITOR=vim 13 export EDITOR=vim
17 export VISUAL=vim
18 export TIG_EDITOR=vim
19 export GIT_EDITOR=vim
20fi 14fi
15export VISUAL=$EDITOR
16export TIG_EDITOR=$EDITOR
17export GIT_EDITOR=$EDITOR
21 18
22# Get current shell 19# Get current shell
23shell=$(</proc/$$/cmdline sed -E 's/(.)-.+$/\1/' | tr -d '[\0\-]') 20shell=$(</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>
78map <leader>pp :setlocal paste!<cr> 78map <leader>pp :setlocal paste!<cr>
79 79
80" Switch CDW to root git directory 80" Switch CDW to root git directory
81nnoremap <Leader>cg :execute 'cd' fnameescape(fnamemodify(finddir('.git', escape(expand('%:p:h'), ' ') . ';'), ':h'))<CR>:pwd<CR> 81nnoremap 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
83map <leader>cd :cd %:p:h<cr>:pwd<cr> 83nnoremap cd :cd %:p:h<cr>:pwd<cr>
84 84
85" Move one line up and down 85" Move one line up and down
86nnoremap <C-j> ddp 86nnoremap <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" })
24vim.keymap.set("n", "<leader>ds", vim.diagnostic.setloclist, { desc = "lsp diagnostic loclist" }) 24vim.keymap.set("n", "<leader>ds", vim.diagnostic.setloclist, { desc = "lsp diagnostic loclist" })
25 25
26-- tabufline 26-- tabufline
27vim.keymap.set("n", "<tab>", function()
28 require("nvchad.tabufline").next()
29end, { desc = "buffer goto next" })
30
31vim.keymap.set("n", "<S-tab>", function()
32 require("nvchad.tabufline").prev()
33end, { desc = "buffer goto prev" })
34
35vim.keymap.set("n", "<leader>x", function() 27vim.keymap.set("n", "<leader>x", function()
36 require("nvchad.tabufline").close_buffer() 28 require("nvchad.tabufline").close_buffer()
37end, { desc = "buffer close" }) 29end, { 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
20o.termguicolors = true 20o.termguicolors = true
21
22o.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"