Skip to content

Commit

Permalink
add full-files
Browse files Browse the repository at this point in the history
  • Loading branch information
gw31415 committed Apr 2, 2024
1 parent 1b96571 commit 2120bb1
Show file tree
Hide file tree
Showing 34 changed files with 2,433 additions and 3 deletions.
4 changes: 4 additions & 0 deletions dot_config/flutter/tool_state
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"is-bot": false,
"license-hash": "595d1dceffbb08773627ff5766d17ddf"
}
17 changes: 17 additions & 0 deletions dot_config/gh/private_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# The current version of the config schema
version: 1
# What protocol to use when performing git operations. Supported values: ssh, https
git_protocol: https
# What editor gh should run when creating issues, pull requests, etc. If blank, will refer to environment.
editor:
# When to interactively prompt. This is a global config that cannot be overridden by hostname. Supported values: enabled, disabled
prompt: enabled
# A pager program to send command output to, e.g. "less". If blank, will refer to environment. Set the value to "cat" to disable the pager.
pager:
# Aliases allow you to create nicknames for gh commands
aliases:
co: pr checkout
# The path to a unix socket through which send HTTP connections. If blank, HTTP traffic will be handled by net/http.DefaultTransport.
http_unix_socket:
# What web browser gh should use when opening URLs. If blank, will refer to environment.
browser:
5 changes: 5 additions & 0 deletions dot_config/gh/private_hosts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
github.com:
git_protocol: https
users:
gw31415:
user: gw31415
1 change: 1 addition & 0 deletions dot_config/git/ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
27 changes: 24 additions & 3 deletions dot_config/nvim/dein/lsp-core.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,29 @@ lua_source = '''
[[plugins]]
repo = "neovim/nvim-lspconfig"
lua_source = '''
local lspconfig = require('lspconfig')
if vim.fn.executable "satysfi-language-server" == 1 then
require('lspconfig')['satysfi-ls'].setup { autostart = true }
lspconfig['satysfi-ls'].setup { autostart = true }
end
-- if vim.fn.executable "sourcekit-lsp" == 1 then
-- require('lspconfig')['sourcekit-lsp'].setup { autostart = true }
-- end
if vim.fn.executable "erg" == 1 then
require('lspconfig')['erg'].setup { autostart = true }
lspconfig['erg'].setup { autostart = true }
end
if vim.fn.executable "gopls" == 1 then
lspconfig['gopls'].setup { autostart = true }
end
if vim.fn.executable "markdown-oxide" then
lspconfig.markdown_oxide.setup({
-- capabilities = capabilities -- ensure that capabilities.workspace.didChangeWatchedFiles.dynamicRegistration = true
root_dir = lspconfig.util.root_pattern('.git', vim.fn.getcwd()), -- this is a temp fix for an error in the lspconfig for this LS
})
end
require('lspconfig')['obsidian'].setup{}
'''

[[plugins]]
Expand Down Expand Up @@ -81,6 +94,14 @@ lua_source = '''
end,
{ buffer = true }
)
-- refresh codelens on TextChanged and InsertLeave as well
vim.api.nvim_create_autocmd({ 'TextChanged', 'InsertLeave', 'CursorHold', 'LspAttach' }, {
buffer = 0,
callback = vim.lsp.codelens.refresh,
})
-- trigger codelens refresh
vim.api.nvim_exec_autocmds('User', { pattern = 'LspAttached' })
-- vim.api.nvim_create_autocmd('BufWritePre', {
-- callback = function() vim.lsp.buf.format { async = false } end,
-- buffer = bufnr,
Expand Down
588 changes: 588 additions & 0 deletions dot_config/private_fish/completions/docker.fish

Large diffs are not rendered by default.

917 changes: 917 additions & 0 deletions dot_config/private_fish/completions/flutter.fish

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
complete fzf_configure_bindings --no-files
complete fzf_configure_bindings --long help --short h --description "Print help" --condition "not __fish_seen_argument --help -h"
complete fzf_configure_bindings --long directory --description "Change the key binding for Search Directory" --condition "not __fish_seen_argument --directory"
complete fzf_configure_bindings --long git_log --description "Change the key binding for Search Git Log" --condition "not __fish_seen_argument --git_log"
complete fzf_configure_bindings --long git_status --description "Change the key binding for Search Git Status" --condition "not __fish_seen_argument --git_status"
complete fzf_configure_bindings --long history --description "Change the key binding for Search History" --condition "not __fish_seen_argument --history"
complete fzf_configure_bindings --long processes --description "Change the key binding for Search Processes" --condition "not __fish_seen_argument --processes"
complete fzf_configure_bindings --long variables --description "Change the key binding for Search Variables" --condition "not __fish_seen_argument --variables"
191 changes: 191 additions & 0 deletions dot_config/private_fish/completions/kubectl.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@

# Copyright 2016 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# fish completion for kubectl -*- shell-script -*-

function __kubectl_debug
set -l file "$BASH_COMP_DEBUG_FILE"
if test -n "$file"
echo "$argv" >> $file
end
end

function __kubectl_perform_completion
__kubectl_debug "Starting __kubectl_perform_completion"

# Extract all args except the last one
set -l args (commandline -opc)
# Extract the last arg and escape it in case it is a space
set -l lastArg (string escape -- (commandline -ct))

__kubectl_debug "args: $args"
__kubectl_debug "last arg: $lastArg"

# Disable ActiveHelp which is not supported for fish shell
set -l requestComp "KUBECTL_ACTIVE_HELP=0 $args[1] __complete $args[2..-1] $lastArg"

__kubectl_debug "Calling $requestComp"
set -l results (eval $requestComp 2> /dev/null)

# Some programs may output extra empty lines after the directive.
# Let's ignore them or else it will break completion.
# Ref: https://github.com/spf13/cobra/issues/1279
for line in $results[-1..1]
if test (string trim -- $line) = ""
# Found an empty line, remove it
set results $results[1..-2]
else
# Found non-empty line, we have our proper output
break
end
end

set -l comps $results[1..-2]
set -l directiveLine $results[-1]

# For Fish, when completing a flag with an = (e.g., <program> -n=<TAB>)
# completions must be prefixed with the flag
set -l flagPrefix (string match -r -- '-.*=' "$lastArg")

__kubectl_debug "Comps: $comps"
__kubectl_debug "DirectiveLine: $directiveLine"
__kubectl_debug "flagPrefix: $flagPrefix"

for comp in $comps
printf "%s%s\n" "$flagPrefix" "$comp"
end

printf "%s\n" "$directiveLine"
end

# This function does two things:
# - Obtain the completions and store them in the global __kubectl_comp_results
# - Return false if file completion should be performed
function __kubectl_prepare_completions
__kubectl_debug ""
__kubectl_debug "========= starting completion logic =========="

# Start fresh
set --erase __kubectl_comp_results

set -l results (__kubectl_perform_completion)
__kubectl_debug "Completion results: $results"

if test -z "$results"
__kubectl_debug "No completion, probably due to a failure"
# Might as well do file completion, in case it helps
return 1
end

set -l directive (string sub --start 2 $results[-1])
set --global __kubectl_comp_results $results[1..-2]

__kubectl_debug "Completions are: $__kubectl_comp_results"
__kubectl_debug "Directive is: $directive"

set -l shellCompDirectiveError 1
set -l shellCompDirectiveNoSpace 2
set -l shellCompDirectiveNoFileComp 4
set -l shellCompDirectiveFilterFileExt 8
set -l shellCompDirectiveFilterDirs 16

if test -z "$directive"
set directive 0
end

set -l compErr (math (math --scale 0 $directive / $shellCompDirectiveError) % 2)
if test $compErr -eq 1
__kubectl_debug "Received error directive: aborting."
# Might as well do file completion, in case it helps
return 1
end

set -l filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2)
set -l dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2)
if test $filefilter -eq 1; or test $dirfilter -eq 1
__kubectl_debug "File extension filtering or directory filtering not supported"
# Do full file completion instead
return 1
end

set -l nospace (math (math --scale 0 $directive / $shellCompDirectiveNoSpace) % 2)
set -l nofiles (math (math --scale 0 $directive / $shellCompDirectiveNoFileComp) % 2)

__kubectl_debug "nospace: $nospace, nofiles: $nofiles"

# If we want to prevent a space, or if file completion is NOT disabled,
# we need to count the number of valid completions.
# To do so, we will filter on prefix as the completions we have received
# may not already be filtered so as to allow fish to match on different
# criteria than the prefix.
if test $nospace -ne 0; or test $nofiles -eq 0
set -l prefix (commandline -t | string escape --style=regex)
__kubectl_debug "prefix: $prefix"

set -l completions (string match -r -- "^$prefix.*" $__kubectl_comp_results)
set --global __kubectl_comp_results $completions
__kubectl_debug "Filtered completions are: $__kubectl_comp_results"

# Important not to quote the variable for count to work
set -l numComps (count $__kubectl_comp_results)
__kubectl_debug "numComps: $numComps"

if test $numComps -eq 1; and test $nospace -ne 0
# We must first split on \t to get rid of the descriptions to be
# able to check what the actual completion will be.
# We don't need descriptions anyway since there is only a single
# real completion which the shell will expand immediately.
set -l split (string split --max 1 \t $__kubectl_comp_results[1])

# Fish won't add a space if the completion ends with any
# of the following characters: @=/:.,
set -l lastChar (string sub -s -1 -- $split)
if not string match -r -q "[@=/:.,]" -- "$lastChar"
# In other cases, to support the "nospace" directive we trick the shell
# by outputting an extra, longer completion.
__kubectl_debug "Adding second completion to perform nospace directive"
set --global __kubectl_comp_results $split[1] $split[1].
__kubectl_debug "Completions are now: $__kubectl_comp_results"
end
end

if test $numComps -eq 0; and test $nofiles -eq 0
# To be consistent with bash and zsh, we only trigger file
# completion when there are no other completions
__kubectl_debug "Requesting file completion"
return 1
end
end

return 0
end

# Since Fish completions are only loaded once the user triggers them, we trigger them ourselves
# so we can properly delete any completions provided by another script.
# Only do this if the program can be found, or else fish may print some errors; besides,
# the existing completions will only be loaded if the program can be found.
if type -q "kubectl"
# The space after the program name is essential to trigger completion for the program
# and not completion of the program name itself.
# Also, we use '> /dev/null 2>&1' since '&>' is not supported in older versions of fish.
complete --do-complete "kubectl " > /dev/null 2>&1
end

# Remove any pre-existing completions for the program since we will be handling all of them.
complete -c kubectl -e

# The call to __kubectl_prepare_completions will setup __kubectl_comp_results
# which provides the program's completion choices.
complete -c kubectl -n '__kubectl_prepare_completions' -f -a '$__kubectl_comp_results'

13 changes: 13 additions & 0 deletions dot_config/private_fish/completions/sxp.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
complete -c sxp -n "__fish_use_subcommand" -s h -l help -d 'Print help'
complete -c sxp -n "__fish_use_subcommand" -f -a "extract" -d 'Extract a single PDF file to SVG files'
complete -c sxp -n "__fish_use_subcommand" -f -a "merge" -d 'Merge SVG files into a single PDF'
complete -c sxp -n "__fish_use_subcommand" -f -a "complete" -d 'Generate shell completions'
complete -c sxp -n "__fish_use_subcommand" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
complete -c sxp -n "__fish_seen_subcommand_from extract" -l prefix -d 'The prefix string of the output files' -r
complete -c sxp -n "__fish_seen_subcommand_from extract" -s h -l help -d 'Print help'
complete -c sxp -n "__fish_seen_subcommand_from merge" -s h -l help -d 'Print help'
complete -c sxp -n "__fish_seen_subcommand_from complete" -s h -l help -d 'Print help'
complete -c sxp -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from extract; and not __fish_seen_subcommand_from merge; and not __fish_seen_subcommand_from complete; and not __fish_seen_subcommand_from help" -f -a "extract" -d 'Extract a single PDF file to SVG files'
complete -c sxp -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from extract; and not __fish_seen_subcommand_from merge; and not __fish_seen_subcommand_from complete; and not __fish_seen_subcommand_from help" -f -a "merge" -d 'Merge SVG files into a single PDF'
complete -c sxp -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from extract; and not __fish_seen_subcommand_from merge; and not __fish_seen_subcommand_from complete; and not __fish_seen_subcommand_from help" -f -a "complete" -d 'Generate shell completions'
complete -c sxp -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from extract; and not __fish_seen_subcommand_from merge; and not __fish_seen_subcommand_from complete; and not __fish_seen_subcommand_from help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
20 changes: 20 additions & 0 deletions dot_config/private_fish/conf.d/android-sdk.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# check for common android sdk locations
for root in $ANDROID_HOME $ANDROID_SDK_ROOT $HOME/Android/Sdk $HOME/Library/Android/sdk
set -l paths
if test -d $root
# the sdk root exists as a directory so let's try to add the binary directories
# we just add the most recent of the build tools that are installed
set -l build_tools_dirs $root/build-tools/*
for bin in $root/cmdline-tools/latest/bin $build_tools_dirs[-1] $root/platform-tools $root/emulator
if test -d $bin
set paths $paths $bin
end
end
# if we added at least one path, let's add them to the real PATH, set ANDROID_HOME and finish
if set -q paths[1]
set -gx PATH $PATH $paths
set -gx ANDROID_HOME $root
break
end
end
end
39 changes: 39 additions & 0 deletions dot_config/private_fish/conf.d/autopair.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
status is-interactive || exit

set --global autopair_left "(" "[" "{" '"' "'"
set --global autopair_right ")" "]" "}" '"' "'"
set --global autopair_pairs "()" "[]" "{}" '""' "''"

function _autopair_fish_key_bindings --on-variable fish_key_bindings
set --query fish_key_bindings[1] || return

test $fish_key_bindings = fish_default_key_bindings &&
set --local mode default insert ||
set --local mode insert default

bind --mode $mode[-1] --erase \177 \b \t

bind --mode $mode[1] \177 _autopair_backspace # macOS ⌫
bind --mode $mode[1] \b _autopair_backspace
bind --mode $mode[1] \t _autopair_tab

printf "%s\n" $autopair_pairs | while read --local left right --delimiter ""
bind --mode $mode[-1] --erase $left $right
if test $left = $right
bind --mode $mode[1] $left "_autopair_insert_same \\$left"
else
bind --mode $mode[1] $left "_autopair_insert_left \\$left \\$right"
bind --mode $mode[1] $right "_autopair_insert_right \\$right"
end
end
end

_autopair_fish_key_bindings

function _autopair_uninstall --on-event autopair_uninstall
string collect (
bind --all | string replace --filter --regex -- "_autopair.*" --erase
set --names | string replace --filter --regex -- "^autopair" "set --erase autopair"
) | source
functions --erase (functions --all | string match "_autopair_*")
end
28 changes: 28 additions & 0 deletions dot_config/private_fish/conf.d/fzf.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# fzf.fish is only meant to be used in interactive mode. If not in interactive mode and not in CI, skip the config to speed up shell startup
if not status is-interactive && test "$CI" != true
exit
end

# Because of scoping rules, to capture the shell variables exactly as they are, we must read
# them before even executing _fzf_search_variables. We use psub to store the
# variables' info in temporary files and pass in the filenames as arguments.
# This variable is global so that it can be referenced by fzf_configure_bindings and in tests
set --global _fzf_search_vars_command '_fzf_search_variables (set --show | psub) (set --names | psub)'


# Install the default bindings, which are mnemonic and minimally conflict with fish's preset bindings
fzf_configure_bindings

# Doesn't erase autoloaded _fzf_* functions because they are not easily accessible once key bindings are erased
function _fzf_uninstall --on-event fzf_uninstall
_fzf_uninstall_bindings

set --erase _fzf_search_vars_command
functions --erase _fzf_uninstall _fzf_migration_message _fzf_uninstall_bindings fzf_configure_bindings
complete --erase fzf_configure_bindings

set_color cyan
echo "fzf.fish uninstalled."
echo "You may need to manually remove fzf_configure_bindings from your config.fish if you were using custom key bindings."
set_color normal
end
1 change: 1 addition & 0 deletions dot_config/private_fish/conf.d/rustup.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
. "$HOME/.cargo/env.fish"
Loading

0 comments on commit 2120bb1

Please sign in to comment.