From bbabd015e7121dd8c0d5e0e9349199e4d56e7edd Mon Sep 17 00:00:00 2001 From: LordMZTE Date: Thu, 9 May 2024 14:55:59 +0200 Subject: [PATCH] implement nushell support --- .config/nushell/config.nu.cgt | 25 ++++++++++++++++++++ .config/nushell/env.nu.cgt | 5 ++++ mzte-nv/conf/lua/pluginconf/p-nu.fnl | 2 ++ mzte-nv/conf/lua/pluginconf/p-treesitter.fnl | 8 +++++-- mzte-nv/conf/lua/plugins.fnl | 3 ++- scripts/prompt/src/prompt.zig | 2 +- scripts/prompt/src/shell.zig | 20 ++++++++++++++++ 7 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 .config/nushell/config.nu.cgt create mode 100644 .config/nushell/env.nu.cgt create mode 100644 mzte-nv/conf/lua/pluginconf/p-nu.fnl diff --git a/.config/nushell/config.nu.cgt b/.config/nushell/config.nu.cgt new file mode 100644 index 0000000..ec89f60 --- /dev/null +++ b/.config/nushell/config.nu.cgt @@ -0,0 +1,25 @@ +# The default config record. This is where much of your global configuration is setup. +$env.config = { + show_banner: false + + table: { + mode: reinforced + index_mode: always # "always" show indexes, "never" show indexes, "auto" = show indexes when a table has "index" column + padding: { left: 0, right: 0 } + header_on_separator: true + } + + completions: { + algorithm: "fuzzy" + } + + cursor_shape: { + vi_insert: line + vi_normal: block + } + + edit_mode: vi + shell_integration: true + use_kitty_protocol: true + highlight_resolved_externals: true +} diff --git a/.config/nushell/env.nu.cgt b/.config/nushell/env.nu.cgt new file mode 100644 index 0000000..67f3494 --- /dev/null +++ b/.config/nushell/env.nu.cgt @@ -0,0 +1,5 @@ +# Nushell Environment Config File +# +# version = "0.92.1" + +<% opt.system "prompt setup nu" %> diff --git a/mzte-nv/conf/lua/pluginconf/p-nu.fnl b/mzte-nv/conf/lua/pluginconf/p-nu.fnl new file mode 100644 index 0000000..58604fc --- /dev/null +++ b/mzte-nv/conf/lua/pluginconf/p-nu.fnl @@ -0,0 +1,2 @@ +(local nu (require :nu)) +(nu.setup {}) diff --git a/mzte-nv/conf/lua/pluginconf/p-treesitter.fnl b/mzte-nv/conf/lua/pluginconf/p-treesitter.fnl index 4d255a2..e992bdb 100644 --- a/mzte-nv/conf/lua/pluginconf/p-treesitter.fnl +++ b/mzte-nv/conf/lua/pluginconf/p-treesitter.fnl @@ -7,7 +7,7 @@ ;; Nix based parsers (let [path mztenv.reg.tree_sitter_parsers] (when path - (vim.opt.runtimepath:append path))) + (vim.opt.runtimepath:prepend path))) (var parser-config (parsers.get_parser_configs)) @@ -16,7 +16,11 @@ :branch :main} :filetype :haxe}) -(configs.setup {:highlight {:enable true} +(local install-dir (.. (vim.loop.os_homedir) :/.local/share/nvim/ts-parsers)) +(vim.opt.runtimepath:append install-dir) + +(configs.setup {:parser_install_dir install-dir + :highlight {:enable true} :autotag {:enable true} :indent {:enable true} :playground {:enable true} diff --git a/mzte-nv/conf/lua/plugins.fnl b/mzte-nv/conf/lua/plugins.fnl index a838609..4f78e76 100644 --- a/mzte-nv/conf/lua/plugins.fnl +++ b/mzte-nv/conf/lua/plugins.fnl @@ -33,7 +33,8 @@ :recorder :tsn-actions :dressing - :gitsigns]) + :gitsigns + :nu]) (local errors {}) diff --git a/scripts/prompt/src/prompt.zig b/scripts/prompt/src/prompt.zig index 9e19e37..c75eb55 100644 --- a/scripts/prompt/src/prompt.zig +++ b/scripts/prompt/src/prompt.zig @@ -108,7 +108,7 @@ fn Renderer(comptime Writer: type) type { fn renderShell(self: *Self) !void { switch (self.options.shell) { - .fish => {}, + .fish, .nu => {}, .bash => { const bgcol = Color{ .Grey = 150 }; const fgcol = Color.Black; diff --git a/scripts/prompt/src/shell.zig b/scripts/prompt/src/shell.zig index de8ea4b..de96b29 100644 --- a/scripts/prompt/src/shell.zig +++ b/scripts/prompt/src/shell.zig @@ -11,6 +11,25 @@ const setup_fmtstrs = struct { \\end \\ ; + const nu = + \\$env.PROMPT_COMMAND = {{ || + \\ $env.MZPROMPT_SHELL = "nu" + \\ $env.MZPROMPT_STATUS = $env.LAST_EXIT_CODE + \\ $env.MZPROMPT_VI_MODE = "_none" + \\ $env.MZPROMPT_DURATION = $env.CMD_DURATION_MS + \\ $env.MZPROMPT_JOBS = 0 + \\ {[argv0]s} show + \\}} + \\ + \\$env.PROMPT_COMMAND_RIGHT = "" + \\ + \\$env.PROMPT_INDICATOR = "" + \\$env.PROMPT_INDICATOR_VI_INSERT = "" + \\$env.PROMPT_INDICATOR_VI_NORMAL = "〉" + \\$env.PROMPT_MULTILINE_INDICATOR = "::: " + \\$env.PROMPT_INDICATOR = "" + \\ + ; const bash = \\__mzprompt_show() {{ \\ export MZPROMPT_STATUS="$?" @@ -27,6 +46,7 @@ const setup_fmtstrs = struct { pub const Shell = enum { fish, + nu, bash, pub fn writeInitCode(self: Shell, argv0: []const u8, writer: anytype) !void {