From abdb414b2f85993b237c5a9cd940e0745d141a40 Mon Sep 17 00:00:00 2001 From: fcying Date: Sat, 19 Oct 2024 00:13:09 +0800 Subject: [PATCH] feat: add tiny-inline-diagnostic, update nushell config --- etc/init_conf.sh | 3 +- etc/{ => nushell}/config.nu | 217 ++++--------------------- etc/nushell/empty.nu | 0 etc/{ => nushell}/env.nu | 32 ++-- etc/nushell/solarized-light.nu | 134 +++++++++++++++ etc/zshrc | 16 +- lua/_lazy.lua | 2 + lua/lsp.lua | 39 +++-- lua/plugins/blink.lua | 93 ++++++----- lua/plugins/tiny_inline_diagnostic.lua | 21 +++ lua/plugins/treesitter.lua | 2 +- 11 files changed, 279 insertions(+), 280 deletions(-) rename etc/{ => nushell}/config.nu (77%) create mode 100644 etc/nushell/empty.nu rename etc/{ => nushell}/env.nu (73%) create mode 100755 etc/nushell/solarized-light.nu create mode 100644 lua/plugins/tiny_inline_diagnostic.lua diff --git a/etc/init_conf.sh b/etc/init_conf.sh index ede56f5b..3f2ff582 100755 --- a/etc/init_conf.sh +++ b/etc/init_conf.sh @@ -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 diff --git a/etc/config.nu b/etc/nushell/config.nu similarity index 77% rename from etc/config.nu rename to etc/nushell/config.nu index 26ec1524..b24e7cef 100644 --- a/etc/config.nu +++ b/etc/nushell/config.nu @@ -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| @@ -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. } @@ -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 } @@ -234,7 +79,6 @@ $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 @@ -242,32 +86,13 @@ $env.config = { 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= - 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. @@ -284,7 +109,6 @@ $env.config = { } plugins: { # alternate configuration for specific plugins, by name, for example: - # # gstat: { # enabled: false # } @@ -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 diff --git a/etc/nushell/empty.nu b/etc/nushell/empty.nu new file mode 100644 index 00000000..e69de29b diff --git a/etc/env.nu b/etc/nushell/env.nu similarity index 73% rename from etc/env.nu rename to etc/nushell/env.nu index bd579f00..a13e7ab3 100644 --- a/etc/env.nu +++ b/etc/nushell/env.nu @@ -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) @@ -74,21 +73,18 @@ $env.NU_PLUGIN_DIRS = [ ($nu.default-config-dir | path join 'plugins') # add /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") + diff --git a/etc/nushell/solarized-light.nu b/etc/nushell/solarized-light.nu new file mode 100755 index 00000000..04d83e75 --- /dev/null +++ b/etc/nushell/solarized-light.nu @@ -0,0 +1,134 @@ +# Retrieve the theme settings +export def main [] { + return { + binary: '#6c71c4' + block: '#268bd2' + cell-path: '#586e75' + closure: '#2aa198' + custom: '#002b36' + duration: '#b58900' + float: '#dc322f' + glob: '#002b36' + int: '#6c71c4' + list: '#2aa198' + nothing: '#dc322f' + range: '#b58900' + record: '#2aa198' + string: '#859900' + + bool: {|| if $in { '#2aa198' } else { '#b58900' } } + + date: {|| (date now) - $in | + if $in < 1hr { + { fg: '#dc322f' attr: 'b' } + } else if $in < 6hr { + '#dc322f' + } else if $in < 1day { + '#b58900' + } else if $in < 3day { + '#859900' + } else if $in < 1wk { + { fg: '#859900' attr: 'b' } + } else if $in < 6wk { + '#2aa198' + } else if $in < 52wk { + '#268bd2' + } else { 'dark_gray' } + } + + filesize: {|e| + if $e == 0b { + '#586e75' + } else if $e < 1mb { + '#2aa198' + } else {{ fg: '#268bd2' }} + } + + shape_and: { fg: '#6c71c4' attr: 'b' } + shape_binary: { fg: '#6c71c4' attr: 'b' } + shape_block: { fg: '#268bd2' attr: 'b' } + shape_bool: '#2aa198' + shape_closure: { fg: '#2aa198' attr: 'b' } + shape_custom: '#859900' + shape_datetime: { fg: '#2aa198' attr: 'b' } + shape_directory: '#2aa198' + shape_external: '#2aa198' + shape_external_resolved: '#2aa198' + shape_externalarg: { fg: '#859900' attr: 'b' } + shape_filepath: '#2aa198' + shape_flag: { fg: '#268bd2' attr: 'b' } + shape_float: { fg: '#dc322f' attr: 'b' } + shape_garbage: { fg: '#FFFFFF' bg: '#FF0000' attr: 'b' } + shape_glob_interpolation: { fg: '#2aa198' attr: 'b' } + shape_globpattern: { fg: '#2aa198' attr: 'b' } + shape_int: { fg: '#6c71c4' attr: 'b' } + shape_internalcall: { fg: '#2aa198' attr: 'b' } + shape_keyword: { fg: '#6c71c4' attr: 'b' } + shape_list: { fg: '#2aa198' attr: 'b' } + shape_literal: '#268bd2' + shape_match_pattern: '#859900' + shape_matching_brackets: { attr: 'u' } + shape_nothing: '#dc322f' + shape_operator: '#b58900' + shape_or: { fg: '#6c71c4' attr: 'b' } + shape_pipe: { fg: '#6c71c4' attr: 'b' } + shape_range: { fg: '#b58900' attr: 'b' } + shape_raw_string: { fg: '#002b36' attr: 'b' } + shape_record: { fg: '#2aa198' attr: 'b' } + shape_redirection: { fg: '#6c71c4' attr: 'b' } + shape_signature: { fg: '#859900' attr: 'b' } + shape_string: '#859900' + shape_string_interpolation: { fg: '#2aa198' attr: 'b' } + shape_table: { fg: '#268bd2' attr: 'b' } + shape_vardecl: { fg: '#268bd2' attr: 'u' } + shape_variable: '#6c71c4' + + foreground: '#586e75' + background: '#fdf6e3' + cursor: '#586e75' + + empty: '#268bd2' + header: { fg: '#859900' attr: 'b' } + hints: '#839496' + leading_trailing_space_bg: { attr: 'n' } + row_index: { fg: '#859900' attr: 'b' } + search_result: { fg: '#dc322f' bg: '#586e75' } + separator: '#586e75' + } +} + +# Update the Nushell configuration +export def --env "set color_config" [] { + $env.config.color_config = (main) +} + +# Update terminal colors +export def "update terminal" [] { + let theme = (main) + + # Set terminal colors + let osc_screen_foreground_color = '10;' + let osc_screen_background_color = '11;' + let osc_cursor_color = '12;' + + $" + (ansi -o $osc_screen_foreground_color)($theme.foreground)(char bel) + (ansi -o $osc_screen_background_color)($theme.background)(char bel) + (ansi -o $osc_cursor_color)($theme.cursor)(char bel) + " + # Line breaks above are just for source readability + # but create extra whitespace when activating. Collapse + # to one line and print with no-newline + | str replace --all "\n" '' + | print -n $"($in)\r" +} + +export module activate { + export-env { + set color_config + update terminal + } +} + +# Activate the theme when sourced +use activate \ No newline at end of file diff --git a/etc/zshrc b/etc/zshrc index 6844892b..629d0645 100644 --- a/etc/zshrc +++ b/etc/zshrc @@ -119,17 +119,17 @@ bindkey '^xe' edit-command-line bindkey '^x^e' edit-command-line ### zinit {{{ -ZINIT_DIR=$HOME/.zinit -if [ ! -f "$ZINIT_DIR/bin/zinit.zsh" ]; then +ZINIT_HOME=$HOME/.zinit +if [ ! -d "$ZINIT_HOME/bin/.git" ]; then zinit_inited="true" - mkdir ~/.zinit - git clone --depth 1 https://github.com/zdharma-continuum/zinit "$ZINIT_DIR"/bin + mkdir -p $ZINIT_HOME/bin + git clone --depth 1 https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"/bin fi declare -A ZINIT ZINIT[NO_ALIASES]=1 -source "$ZINIT_DIR/bin/zinit.zsh" -autoload -Uz _zinit -(( ${+_comps} )) && _comps[zinit]=_zinit +source "${ZINIT_HOME}/bin/zinit.zsh" +# autoload -Uz _zinit +# (( ${+_comps} )) && _comps[zinit]=_zinit #zinit light Aloxaf/fzf-tab @@ -149,7 +149,7 @@ else zinit light zsh-users/zsh-autosuggestions unset ZSH_AUTOSUGGEST_USE_ASYNC fi -bindkey '^K' autosuggest-accept +bindkey '^f' autosuggest-accept zinit ice wait'0' lucid atinit'zpcompinit; zpcdreplay' zinit light zsh-users/zsh-syntax-highlighting diff --git a/lua/_lazy.lua b/lua/_lazy.lua index 1e32e0f7..df4e1b24 100644 --- a/lua/_lazy.lua +++ b/lua/_lazy.lua @@ -61,6 +61,7 @@ local plugins = { { import = "plugins.markview" }, { "Vimjas/vim-python-pep8-indent", ft = "python" }, { "wsdjeg/vim-autohotkey", ft = "autohotkey" }, + { "elkasztano/nushell-syntax-vim", ft = "nu" }, -- coding {{{ { import = "plugins.gen_clang_conf" }, @@ -69,6 +70,7 @@ local plugins = { { import = "plugins.lazydev" }, { import = vim.g.complete_engine == "blink" and "plugins.blink" or "plugins.cmp" }, { import = "plugins.treesitter" }, + { import = "plugins.tiny_inline_diagnostic" }, { "neovim/nvim-lspconfig", cmd = { "LspInfo", "LspInstall", "LspStart", "LspRestart" }, diff --git a/lua/lsp.lua b/lua/lsp.lua index 5f5f8dd8..d914eeed 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -134,6 +134,7 @@ function configs.ahk2() root_dir = function() return util.root_dir end, + single_file_support = true, } require("lspconfig.configs")["autohotkey2-lsp"] = { default_config = opts } end @@ -146,7 +147,23 @@ function configs.bashls() shellcheckArguments = "-e SC1090,SC1091,SC1094,SC2010,SC2012,SC2015,SC2029,SC2046,SC2086," .. "SC2119,SC2120,SC2154,SC2155,SC2164,SC2181,SC2206,SC2317", } - } + }, + single_file_support = true, + } +end + +function configs.nushell() + lsp_opts["nushell"] = { + cmd = { + "nu", + "-I", + vim.fn.getcwd(), + "--no-config-file", + "--lsp", + }, + filetypes = { "nu" }, + root_dir = function() return util.root_dir end, + single_file_support = true, } end @@ -269,18 +286,7 @@ function M.setup() api.nvim_create_user_command("Format", function() require("lsp").format() end, {}) - vim.diagnostic.config({ - virtual_text = false, - float = { - show_header = true, - source = true, - focusable = false, - format = function(diagnostic) - --vim.print(diagnostic) - return string.format("%s\n[%s]", diagnostic.message, diagnostic.user_data.lsp.code) - end, - }, - }) + vim.diagnostic.config({ virtual_text = false }) local capabilities if g.complete_engine == "blink" then @@ -301,8 +307,8 @@ function M.setup() map("n", "gs", vim.lsp.buf.signature_help, opts) map("n", "gt", "Telescope lsp_type_definitions", opts) map("n", "gl", vim.diagnostic.open_float, opts) - map("n", "[d", vim.diagnostic.goto_prev, opts) - map("n", "]d", vim.diagnostic.goto_next, opts) + map("n", "[d", function() vim.diagnostic.goto_next({ float = false }) end, opts) + map("n", "]d", function() vim.diagnostic.goto_next({ float = false }) end, opts) map("n", "la", function() require("actions-preview").code_actions() end, opts) map("n", "ld", "Telescope diagnostics bufnr=0", opts) map("n", "ls", "Telescope lsp_workspace_symbols", opts) @@ -350,9 +356,8 @@ function M.setup() if fn.executable("qmlls") == 1 then lspconfig["qmlls"].setup(lsp_opts["qmlls"]) end - if fn.executable("nu") == 1 then - lspconfig["nushell"].setup({}) + require('lspconfig').nushell.setup(lsp_opts["nushell"]) end end diff --git a/lua/plugins/blink.lua b/lua/plugins/blink.lua index 7580d4f0..1a2252d3 100644 --- a/lua/plugins/blink.lua +++ b/lua/plugins/blink.lua @@ -1,54 +1,53 @@ -return { - "saghen/blink.cmp", - lazy = false, - dependencies = "rafamadriz/friendly-snippets", - - version = nil, - build = 'cargo build --release', - - opts = { - highlight = { - use_nvim_cmp_as_default = true, - }, - -- set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font' - nerd_font_variant = "normal", - -- accept = { auto_brackets = { enabled = true } }, - trigger = { signature_help = { enabled = true } }, +local opts = { + highlight = { + use_nvim_cmp_as_default = true, + }, + -- set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font' + nerd_font_variant = "normal", + -- accept = { auto_brackets = { enabled = true } }, + trigger = { signature_help = { enabled = true } }, - keymap = { - show = "", - hide = "", - accept = "", - select_prev = { "", "", "" }, - select_next = { "", "", "" }, + keymap = { + show = "", + hide = "", + accept = "", + select_prev = { "", "", "" }, + select_next = { "", "", "" }, - show_documentation = {}, - hide_documentation = {}, - scroll_documentation_up = "", - scroll_documentation_down = "", + show_documentation = {}, + hide_documentation = {}, + scroll_documentation_up = "", + scroll_documentation_down = "", - snippet_forward = "", - snippet_backward = "", - }, - sources = { - providers = { - { - { "blink.cmp.sources.lsp" }, - { "blink.cmp.sources.path" }, - { - "blink.cmp.sources.snippets", - score_offset = -3, - opts = { - friendly_snippets = false, - -- search_paths = { vim.g.config_dir .. "/snippets" }, - global_snippets = { "all" }, - extended_filetypes = {}, - ignored_filetypes = {}, - }, - }, + snippet_forward = "", + snippet_backward = "", + }, + sources = { + providers = { + { "blink.cmp.sources.lsp", name = "LSP", score_offset = 0 }, + { "blink.cmp.sources.buffer", name = "Buf", fallback_for = { "LSP" } }, + { "blink.cmp.sources.path", name = "Path", score_offset = 3 }, + { + "blink.cmp.sources.snippets", + name = "Snip", + score_offset = -3, + opts = { + friendly_snippets = true, + search_paths = { vim.g.config_dir .. "/snippets" }, + global_snippets = { "all" }, + extended_filetypes = {}, + ignored_filetypes = {}, }, - { { "blink.cmp.sources.buffer" } }, }, }, - } + }, +} + +return { + "saghen/blink.cmp", + lazy = false, + dependencies = "rafamadriz/friendly-snippets", + version = nil, + build = "cargo build --release", + opts = opts, } diff --git a/lua/plugins/tiny_inline_diagnostic.lua b/lua/plugins/tiny_inline_diagnostic.lua new file mode 100644 index 00000000..937fcd1d --- /dev/null +++ b/lua/plugins/tiny_inline_diagnostic.lua @@ -0,0 +1,21 @@ +local opts = { + options = { + show_source = false, + format = function(diagnostic) + if diagnostic.user_data.lsp.code then + return string.format("%s [%s]", diagnostic.message, diagnostic.user_data.lsp.code) + else + return string.format("%s", diagnostic.message) + end + end, + } +} + +return { + "rachartier/tiny-inline-diagnostic.nvim", + -- event = "LspAttach", + event = "VeryLazy", + config = function() + require("tiny-inline-diagnostic").setup(opts) + end, +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index d038bbcc..69577af2 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -40,7 +40,7 @@ return parser_install_dir = parser_install_dir, ensure_installed = { "vim", "vimdoc", "lua", "query", "comment", - "cpp", "typescript", "vue", "latex", + "cpp", "typescript", "vue" }, sync_install = #vim.api.nvim_list_uis() == 0, auto_install = false,