diff options
author | Yuqian Yang <crupest@crupest.life> | 2025-03-10 16:56:01 +0800 |
---|---|---|
committer | Yuqian Yang <crupest@crupest.life> | 2025-03-10 16:56:01 +0800 |
commit | 117afbc9af2cd4fd515d7fdbda8a1fa44c3d8a74 (patch) | |
tree | e9854d4d64c65f34389869aae2c57888b747fe58 | |
parent | 5cab23279b9482ac02e497b7c2588308d6e3acfc (diff) | |
download | crupest-117afbc9af2cd4fd515d7fdbda8a1fa44c3d8a74.tar.gz crupest-117afbc9af2cd4fd515d7fdbda8a1fa44c3d8a74.tar.bz2 crupest-117afbc9af2cd4fd515d7fdbda8a1fa44c3d8a74.zip |
feat(nvim): add more tools.
-rwxr-xr-x | store/home/bin/neovide-listen | 50 | ||||
-rwxr-xr-x | store/home/bin/nvr-wait | 4 | ||||
-rw-r--r-- | store/home/config/nvim/lua/crupest/nvim/plugins/cmp.lua | 9 |
3 files changed, 38 insertions, 25 deletions
diff --git a/store/home/bin/neovide-listen b/store/home/bin/neovide-listen index 2591842..3bcc7da 100755 --- a/store/home/bin/neovide-listen +++ b/store/home/bin/neovide-listen @@ -1,43 +1,49 @@ #!/usr/bin/env bash -if [[ -z "$NVIM_SOCKET" ]]; then - NVIM_SOCKET="/tmp/nvimsocket" -fi +export CRU_NVIM_SERVER=${CRU_NVIM_SERVER:-/tmp/nvimsocket} args=() -MY_NEOVIM_PATH="$HOME/codes/neovim/build/bin/nvim" -if [[ -e "$MY_NEOVIM_PATH" ]]; then - echo "Found my neovim at $MY_NEOVIM_PATH" - export VIMRUNTIME="$HOME/codes/neovim/runtime" - args=("${args[@]}" "--neovim-bin" "$MY_NEOVIM_PATH") + +self_built_nvim="$HOME/codes/neovim/build/bin/nvim" +self_built_nvim_runtime="$HOME/codes/neovim/runtime" +if [[ -z "$CRU_NVIM" ]] && [[ -e "$self_built_nvim" ]]; then + echo "Found self-built neovim at $CRU_NVIM" + CRU_NVIM="$self_built_nvim" + CRU_VIMRUNTIME="$self_built_nvim_runtime" +fi + +[[ -z "$CRU_NVIM" ]] || args=("${args[@]}" "--neovim-bin" "$CRU_NVIM") +export CRU_NVIM=${CRU_NVIM:-nvim} +[[ -z "$CRU_VIMRUNTIME" ]] || export VIMRUNTIME="$CRU_VIMRUNTIME" + +self_built_neovide="$HOME/codes/neovide/target/release/neovide" +if [[ -z "$CRU_NEOVIDE" ]] && [[ -e "$self_built_neovide" ]]; then + echo "Found self-build of neovide at $self_built_neovide" + CRU_NEOVIDE="$self_built_neovide" fi +export CRU_NEOVIDE=${CRU_NEOVIDE:-neovide} listen_added=0 for arg in "$@"; do args=("${args[@]}" "$arg") - if [ "$arg" = '--' ]; then - args=("${args[@]}" "--listen" "$NVIM_SOCKET") + if [[ "$arg" == "--" ]]; then + args=("${args[@]}" "--listen" "$CRU_NVIM_SERVER") listen_added=1 fi done if [[ $listen_added = 0 ]]; then - args=("${args[@]}" "--" "--listen" "$NVIM_SOCKET") -fi - -NEOVIDE_BIN=neovide -MY_NEOVIDE_PATH="$HOME/codes/neovide/target/release/neovide" -if [ -e "$MY_NEOVIDE_PATH" ]; then - echo "Found my neovide at $MY_NEOVIDE_PATH" - NEOVIDE_BIN="$MY_NEOVIDE_PATH" + args=("${args[@]}" "--" "--listen" "$CRU_NVIM_SERVER") fi if which nvr > /dev/null; then - echo "Detected nvr, set git editor env" - export GIT_EDITOR='nvr -cc split --remote-wait' + echo "Found nvr, set VISUAL EDITOR GIT_EDITOR to nvr-wait" + export VISUAL="nvr-wait" + export EDITOR="$VISUAL" + export GIT_EDITOR="$VISUAL" fi -args=("$NEOVIDE_BIN" "${args[@]}") -echo "Command is ${args[@]}" +args=("$CRU_NEOVIDE" "${args[@]}") +echo "Full command is ${args[@]}" exec "${args[@]}" diff --git a/store/home/bin/nvr-wait b/store/home/bin/nvr-wait new file mode 100755 index 0000000..410d42d --- /dev/null +++ b/store/home/bin/nvr-wait @@ -0,0 +1,4 @@ +#!/bin/sh + +export CRU_NVIM_SERVER=${CRU_NVIM_SERVER:-/tmp/nvimsocket} +exec nvr --nostart --servername "$CRU_NVIM_SERVER" -cc split --remote-wait "$@" diff --git a/store/home/config/nvim/lua/crupest/nvim/plugins/cmp.lua b/store/home/config/nvim/lua/crupest/nvim/plugins/cmp.lua index 9b1d876..2244443 100644 --- a/store/home/config/nvim/lua/crupest/nvim/plugins/cmp.lua +++ b/store/home/config/nvim/lua/crupest/nvim/plugins/cmp.lua @@ -9,13 +9,16 @@ local function setup() end, }, window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), }, mapping = cmp.mapping.preset.insert({ ['<C-b>'] = cmp.mapping.scroll_docs(-4), ['<C-f>'] = cmp.mapping.scroll_docs(4), - ['<C-Space>'] = cmp.mapping.complete(), - ['<C-e>'] = cmp.mapping.abort(), - ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + ['<C-j>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }), + ['<C-k>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), + ['<C-y>'] = cmp.mapping.confirm({ select = true }), + ['<CR>'] = cmp.mapping.confirm({ select = true }), }), sources = cmp.config.sources({ { name = 'nvim_lsp' }, |