Skip to content

Commit

Permalink
feat: add tiny-inline-diagnostic, update nushell config
Browse files Browse the repository at this point in the history
  • Loading branch information
fcying committed Oct 20, 2024
1 parent 88a7dd2 commit abdb414
Show file tree
Hide file tree
Showing 11 changed files with 279 additions and 280 deletions.
3 changes: 1 addition & 2 deletions etc/init_conf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ if [[ $app == "ln" ]]; then
ln -sfv $PWD/.clang-format ~/

mkdir -p ~/.config/nushell
ln -sfv $PWD/env.nu ~/.config/nushell
ln -sfv $PWD/config.nu ~/.config/nushell
ln -sfv $PWD/nushell/*.nu ~/.config/nushell

fi

Expand Down
217 changes: 30 additions & 187 deletions etc/config.nu → etc/nushell/config.nu
Original file line number Diff line number Diff line change
@@ -1,144 +1,4 @@
# Nushell Config File
#
# version = "0.98.0"

# For more information on defining custom themes, see
# https://www.nushell.sh/book/coloring_and_theming.html
# And here is the theme collection
# https://github.com/nushell/nu_scripts/tree/main/themes
let dark_theme = {
# color for nushell primitives
separator: white
leading_trailing_space_bg: { attr: n } # no fg, no bg, attr none effectively turns this off
header: green_bold
empty: blue
# Closures can be used to choose colors for specific values.
# The value (in this case, a bool) is piped into the closure.
# eg) {|| if $in { 'light_cyan' } else { 'light_gray' } }
bool: light_cyan
int: white
filesize: cyan
duration: white
date: purple
range: white
float: white
string: white
nothing: white
binary: white
cell-path: white
row_index: green_bold
record: white
list: white
block: white
hints: dark_gray
search_result: { bg: red fg: white }
shape_and: purple_bold
shape_binary: purple_bold
shape_block: blue_bold
shape_bool: light_cyan
shape_closure: green_bold
shape_custom: green
shape_datetime: cyan_bold
shape_directory: cyan
shape_external: cyan
shape_externalarg: green_bold
shape_external_resolved: light_yellow_bold
shape_filepath: cyan
shape_flag: blue_bold
shape_float: purple_bold
# shapes are used to change the cli syntax highlighting
shape_garbage: { fg: white bg: red attr: b }
shape_glob_interpolation: cyan_bold
shape_globpattern: cyan_bold
shape_int: purple_bold
shape_internalcall: cyan_bold
shape_keyword: cyan_bold
shape_list: cyan_bold
shape_literal: blue
shape_match_pattern: green
shape_matching_brackets: { attr: u }
shape_nothing: light_cyan
shape_operator: yellow
shape_or: purple_bold
shape_pipe: purple_bold
shape_range: yellow_bold
shape_record: cyan_bold
shape_redirection: purple_bold
shape_signature: green_bold
shape_string: green
shape_string_interpolation: cyan_bold
shape_table: blue_bold
shape_variable: purple
shape_vardecl: purple
shape_raw_string: light_purple
}

let light_theme = {
# color for nushell primitives
separator: dark_gray
leading_trailing_space_bg: { attr: n } # no fg, no bg, attr none effectively turns this off
header: green_bold
empty: blue
# Closures can be used to choose colors for specific values.
# The value (in this case, a bool) is piped into the closure.
# eg) {|| if $in { 'dark_cyan' } else { 'dark_gray' } }
bool: dark_cyan
int: dark_gray
filesize: cyan_bold
duration: dark_gray
date: purple
range: dark_gray
float: dark_gray
string: dark_gray
nothing: dark_gray
binary: dark_gray
cell-path: dark_gray
row_index: green_bold
record: dark_gray
list: dark_gray
block: dark_gray
hints: dark_gray
search_result: { fg: white bg: red }
shape_and: purple_bold
shape_binary: purple_bold
shape_block: blue_bold
shape_bool: light_cyan
shape_closure: green_bold
shape_custom: green
shape_datetime: cyan_bold
shape_directory: cyan
shape_external: cyan
shape_externalarg: green_bold
shape_external_resolved: light_purple_bold
shape_filepath: cyan
shape_flag: blue_bold
shape_float: purple_bold
# shapes are used to change the cli syntax highlighting
shape_garbage: { fg: white bg: red attr: b }
shape_glob_interpolation: cyan_bold
shape_globpattern: cyan_bold
shape_int: purple_bold
shape_internalcall: cyan_bold
shape_keyword: cyan_bold
shape_list: cyan_bold
shape_literal: blue
shape_match_pattern: green
shape_matching_brackets: { attr: u }
shape_nothing: light_cyan
shape_operator: yellow
shape_or: purple_bold
shape_pipe: purple_bold
shape_range: yellow_bold
shape_record: cyan_bold
shape_redirection: purple_bold
shape_signature: green_bold
shape_string: green
shape_string_interpolation: cyan_bold
shape_table: blue_bold
shape_variable: purple
shape_vardecl: purple
shape_raw_string: light_purple
}

# External completer example
# let carapace_completer = {|spans|
Expand Down Expand Up @@ -182,30 +42,15 @@ $env.config = {
termination_signal: true
}

# datetime_format determines what a datetime rendered in the shell would look like.
# Behavior without this configuration point will be to "humanize" the datetime display,
# showing something like "a day ago."
datetime_format: {
# normal: '%a, %d %b %Y %H:%M:%S %z' # shows up in displays of variables or other datetime's outside of tables
# table: '%m/%d/%y %I:%M:%S%p' # generally shows up in tabular outputs such as ls. commenting this out will change it to the default human readable datetime format
}

explore: {
status_bar_background: { fg: "#1D1F21", bg: "#C4C9C6" },
command_bar_text: { fg: "#C4C9C6" },
highlight: { fg: "black", bg: "yellow" },
status: {
error: { fg: "white", bg: "red" },
warn: {}
info: {}
},
selected_cell: { bg: light_blue },
normal: '%a, %d %b %Y %H:%M:%S %z', # shows up in displays of variables or other datetime's outside of tables
table: '%y/%m/%d/ %H:%M:%S',
}

history: {
max_size: 100_000 # Session has to be reloaded for this to take effect
sync_on_enter: true # Enable to share history between multiple sessions, else you have to close the session to write history to file
file_format: "plaintext" # "sqlite" or "plaintext"
file_format: "sqlite" # "sqlite" or "plaintext"
isolation: false # only available with sqlite file_format. true enables history isolation, false disables it. true will allow the history to be isolated to the current session using up/down arrows. false will allow the history to be shared across all sessions.
}

Expand All @@ -224,7 +69,7 @@ $env.config = {
}

filesize: {
metric: false # true => KB, MB, GB (ISO standard), false => KiB, MiB, GiB (Windows standard)
metric: true # true => KB, MB, GB (ISO standard), false => KiB, MiB, GiB (Windows standard)
format: "auto" # b, kb, kib, mb, mib, gb, gib, tb, tib, pb, pib, eb, eib, auto
}

Expand All @@ -234,40 +79,20 @@ $env.config = {
vi_normal: underscore # block, underscore, line, blink_block, blink_underscore, blink_line, inherit to skip setting cursor shape (underscore is the default)
}

color_config: $dark_theme # if you want a more interesting theme, you can replace the empty record with `$dark_theme`, `$light_theme` or another custom record
footer_mode: 25 # always, never, number_of_rows, auto
float_precision: 2 # the precision for displaying floats in tables
buffer_editor: null # command that will be used to edit the current line buffer with ctrl+o, if unset fallback to $env.EDITOR and $env.VISUAL
use_ansi_coloring: true
bracketed_paste: true # enable bracketed paste, currently useless on windows
edit_mode: emacs # emacs, vi
shell_integration: {
# osc2 abbreviates the path if in the home_dir, sets the tab/window title, shows the running command in the tab/window title
osc2: true
# osc7 is a way to communicate the path to the terminal, this is helpful for spawning new tabs in the same directory
osc7: true
# osc8 is also implemented as the deprecated setting ls.show_clickable_links, it shows clickable links in ls output if your terminal supports it. show_clickable_links is deprecated in favor of osc8
osc8: true
# osc9_9 is from ConEmu and is starting to get wider support. It's similar to osc7 in that it communicates the path to the terminal
osc9_9: false
# osc133 is several escapes invented by Final Term which include the supported ones below.
# 133;A - Mark prompt start
# 133;B - Mark prompt end
# 133;C - Mark pre-execution
# 133;D;exit - Mark execution finished with exit code
# This is used to enable terminals to know where the prompt is, the command is, where the command finishes, and where the output of the command is
osc2: true # abbreviates the path if in the home_dir
osc7: true # a way to communicate the path to the terminal
osc8: true # shows clickable links in ls output if your terminal supports it.
osc9_9: false # starting to get wider support.
osc133: true
# osc633 is closely related to osc133 but only exists in visual studio code (vscode) and supports their shell integration features
# 633;A - Mark prompt start
# 633;B - Mark prompt end
# 633;C - Mark pre-execution
# 633;D;exit - Mark execution finished with exit code
# 633;E - Explicitly set the command line with an optional nonce
# 633;P;Cwd=<path> - Mark the current working directory and communicate it to the terminal
# and also helps with the run recent menu in vscode
osc633: true
# reset_application_mode is escape \x1b[?1l and was added to help ssh work better
reset_application_mode: true
reset_application_mode: true # escape \x1b[?1l and was added to help ssh work better
}
render_right_prompt_on_last_line: false # true or false to enable or disable right prompt to be rendered on last line of the prompt.
use_kitty_protocol: false # enables keyboard enhancement protocol implemented by kitty console, only if your terminal support this.
Expand All @@ -284,7 +109,6 @@ $env.config = {
}
plugins: {
# alternate configuration for specific plugins, by name, for example:
#
# gstat: {
# enabled: false
# }
Expand Down Expand Up @@ -894,16 +718,35 @@ $env.config = {
mode: emacs
event: { edit: selectall }
}
{
name: "fzf file"
modifier: control
keycode: char_t
mode: [emacs, vi_normal, vi_insert]
event: {
send: executehostcommand
cmd: "commandline edit --replace (fzf --reverse --height 40%)"
}
},
]
}

# https://www.nushell.sh/book/coloring_and_theming.html
# https://github.com/nushell/nu_scripts/tree/main/themes
use ($nu.default-config-dir | path join "solarized-light.nu")
solarized-light set color_config

if (which atuin | is-not-empty) {
source ($nu.default-config-dir | path join "atuin.nu")
source (if (($nu.default-config-dir | path join "atuin.nu") | path expand | path exists) {($nu.default-config-dir | path join "atuin.nu")} else {"empty.nu"})
}
source ($nu.default-config-dir | path join "zlua.nu")

alias vim = nvim
alias vim = if (which nvim | is-not-empty) {nvim} else {vim}
alias z = _zlua
alias zb = _zlua -b
alias zi = _zlua -i

alias ll = ls -la

alias gst = git status
alias gaa = git add --all
Expand Down
Empty file added etc/nushell/empty.nu
Empty file.
32 changes: 14 additions & 18 deletions etc/env.nu → etc/nushell/env.nu
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ def create_right_prompt [] {
let time_segment = ([
(ansi reset)
(ansi magenta)
(date now | format date '%x %X') # try to respect user's locale
] | str join | str replace --regex --all "([/:])" $"(ansi green)${1}(ansi magenta)" |
str replace --regex --all "([AP]M)" $"(ansi magenta_underline)${1}")
(date now | format date '%y/%m/%d %H:%M:%S')
] | str join | str replace --regex --all "([/:])" $"(ansi green)${1}(ansi magenta)")

let last_exit_code = if ($env.LAST_EXIT_CODE != 0) {([
(ansi rb)
Expand Down Expand Up @@ -74,21 +73,18 @@ $env.NU_PLUGIN_DIRS = [
($nu.default-config-dir | path join 'plugins') # add <nushell-config-dir>/plugins
]

# To add entries to PATH (on Windows you might use Path), you can use the following pattern:
# $env.PATH = ($env.PATH | split row (char esep) | prepend '/some/path')
# An alternate way to add entries to $env.PATH is to use the custom command `path add`
# which is built into the nushell stdlib:
# use std "path add"
# $env.PATH = ($env.PATH | split row (char esep))
# path add /some/path
# path add ($env.CARGO_HOME | path join "bin")
# path add ($env.HOME | path join ".local" "bin")
# $env.PATH = ($env.PATH | uniq)
$env.OS = (sys host).name
use std "path add"

# To load from a custom file you can use:
# source ($nu.default-config-dir | path join 'custom.nu')
if $env.OS == "Windows" {
lua D:/tool/scoop/apps/z.lua/current/z.lua --init nushell | save -f ($nu.default-config-dir | path join "zlua.nu")
} else {
path add ($env.HOME | path join "go/bin" "bin")
$env.PATH = ($env.PATH | uniq)

if (which atuin | is-not-empty) {
atuin init nu | save -f ($nu.default-config-dir | path join "atuin.nu")
if (which atuin | is-not-empty) {
atuin init nu | save -f ($nu.default-config-dir | path join "atuin.nu")
}
lua ~/bin/z.lua --init nushell | save -f ($nu.default-config-dir | path join "zlua.nu")
}
lua ~/bin/z.lua --init nushell | save -f ($nu.default-config-dir | path join "zlua.nu")

Loading

0 comments on commit abdb414

Please sign in to comment.