From 29bc68c1515f734d31527182157dea0d9d4c9306 Mon Sep 17 00:00:00 2001 From: elkowar <5300871+elkowar@users.noreply.github.com> Date: Mon, 10 May 2021 15:53:33 +0200 Subject: [PATCH] Show path in bar --- files/.config/nvim/fnl/plugins.fnl | 4 ++ files/.config/nvim/fnl/plugins/bufferline.fnl | 21 +++--- files/.config/nvim/fnl/plugins/galaxyline.fnl | 65 +++++++++---------- files/.config/nvim/fnl/utils.fnl | 14 +++- 4 files changed, 61 insertions(+), 43 deletions(-) diff --git a/files/.config/nvim/fnl/plugins.fnl b/files/.config/nvim/fnl/plugins.fnl index b0e5c4a..e5761be 100644 --- a/files/.config/nvim/fnl/plugins.fnl +++ b/files/.config/nvim/fnl/plugins.fnl @@ -10,6 +10,8 @@ :cmd ["Telescope"] :requires [:nvim-lua/popup.nvim :nvim-lua/plenary.nvim]} + :kyazdani42/nvim-web-devicons {} + :p00f/nvim-ts-rainbow {} :romgrk/nvim-treesitter-context {} :JoosepAlviste/nvim-ts-context-commentstring {} @@ -107,6 +109,8 @@ :simrat39/rust-tools.nvim {:ft ["rust"]} :ray-x/lsp_signature.nvim {} + :vmchale/ats-vim {:ft ["ats"]} + :bakpakin/fennel.vim {}) ; >>> diff --git a/files/.config/nvim/fnl/plugins/bufferline.fnl b/files/.config/nvim/fnl/plugins/bufferline.fnl index 313be80..62e103d 100644 --- a/files/.config/nvim/fnl/plugins/bufferline.fnl +++ b/files/.config/nvim/fnl/plugins/bufferline.fnl @@ -7,13 +7,14 @@ colors colors}}) ; :h bufferline-lua-highlights -(let [selected {:guibg colors.neutral_aqua :guifg colors.dark0 :gui ""} - visible {:guibg colors.dark1 :guifg colors.neutral_aqua :gui ""}] +(let [selected {:gui "" :guibg colors.neutral_aqua :guifg colors.dark0} + visible {:gui "" :guibg colors.dark1 :guifg colors.neutral_aqua}] (bufferline.setup {:options {:diagnostics "nvim_lsp" :diagnostics_indicator (fn [cnt lvl diagnostics-dict] (.. " (" cnt ")")) :show_buffer_close_icons false + :show_buffer_icons false :show_close_icon false :show_tab_indicators false :enforce_regular_tabs false @@ -39,18 +40,22 @@ :duplicate_visible visible :duplicate_selected selected - :diagnostic {:gui "" :guibg colors.dark1 :guifg colors.neutral_red} - :diagnostic_visible {:gui "" :guibg colors.dark1 :guifg colors.neutral_red} - :diagnostic_selected {:gui "" :guibg colors.neutral_aqua :guifg colors.faded_red} + :diagnostic {:gui "" :guibg colors.dark1 :guifg colors.neutral_red} + :diagnostic_visible {:gui "" :guibg colors.dark1 :guifg colors.neutral_red} + :diagnostic_selected {:gui "" :guibg colors.neutral_aqua :guifg colors.faded_red} - :info_diagnostic {:gui "" :guibg colors.dark1 :guifg colors.neutral_blue} - :info_diagnostic_visible {:gui "" :guibg colors.dark1 :guifg colors.neutral_blue} - :info_diagnostic_selected {:gui "" :guibg colors.neutral_aqua :guifg colors.faded_blue} + :info_diagnostic {:gui "" :guibg colors.dark1 :guifg colors.neutral_blue} + :info_diagnostic_visible {:gui "" :guibg colors.dark1 :guifg colors.neutral_blue} + :info_diagnostic_selected {:gui "" :guibg colors.neutral_aqua :guifg colors.faded_blue} :warning_diagnostic {:gui "" :guibg colors.dark1 :guifg colors.neutral_yellow} :warning_diagnostic_visible {:gui "" :guibg colors.dark1 :guifg colors.neutral_yellow} :warning_diagnostic_selected {:gui "" :guibg colors.neutral_aqua :guifg colors.faded_yellow} + :error_diagnostic {:gui "" :guibg colors.dark1 :guifg colors.neutral_red} + :error_diagnostic_visible {:gui "" :guibg colors.dark1 :guifg colors.neutral_red} + :error_diagnostic_selected {:gui "" :guibg colors.neutral_aqua :guifg colors.red} + :separator visible :indicator_selected {:guibg colors.neutral_aqua :guifg colors.neutral_aqua} diff --git a/files/.config/nvim/fnl/plugins/galaxyline.fnl b/files/.config/nvim/fnl/plugins/galaxyline.fnl index ebecea7..28c6d85 100644 --- a/files/.config/nvim/fnl/plugins/galaxyline.fnl +++ b/files/.config/nvim/fnl/plugins/galaxyline.fnl @@ -1,5 +1,6 @@ (module plugins.galaxyline {require {a aniseed.core + str aniseed.string fennel aniseed.fennel nvim aniseed.nvim utils utils @@ -18,7 +19,7 @@ (local modes {:n {:text "NORMAL" :colors {:bg colors.neutral_aqua :fg colors.dark0}} :i {:text "INSERT" :colors {:bg colors.neutral_yellow :fg colors.dark0}} - :c {:text "CMD" :colors {:bg colors.neutral_aqua :fg colors.dark0}} + :c {:text "CMMAND" :colors {:bg colors.neutral_aqua :fg colors.dark0}} :ce {:text "NORMEX" :colors {:bg colors.neutral_aqua :fg colors.dark0}} :cv {:text "EX" :colors {:bg colors.neutral_aqua :fg colors.dark0}} :ic {:text "INSCOMP" :colors {:bg colors.neutral_aqua :fg colors.dark0}} @@ -34,52 +35,46 @@ :V {:text "VISUAL LINE" :colors {:bg colors.neutral_blue :fg colors.dark0}} "" {:text "VISUAL BLOCK" :colors {:bg colors.neutral_blue :fg colors.dark0}}}) +(fn get-current-filename [] + (nvim.fn.expand "%:t")) -(fn buf-name-empty? [] - (a.empty? (nvim.fn.expand "%:t"))) - -(fn get-current-file-name [] - (let [file (nvim.fn.expand "%:t")] +(fn get-current-filepath [] + (let [file (utils.shorten-path (vim.fn.bufname) 5 50)] (if (a.empty? file) "" nvim.bo.readonly (.. "RO " file) (and nvim.bo.modifiable nvim.bo.modified) (.. file " ") file))) -(fn get-mode-data [] - (or (. modes (nvim.fn.mode)) - {:text (nvim.fn.mode) - :colors {:bg colors.neutral_orange :fg colors.dark0}})) - -(fn vim-mode-provider [] - (let [modedata (get-mode-data)] - (utils.highlight "GalaxyViMode" modedata.colors) - (.. " " modedata.text " "))) - - - (set galaxyline.short_line_list ["dbui" "diff" "peekaboo" "undotree" "vista" "vista_markdown"]) - -(set galaxyline.section.left - [{:ViMode {:provider vim-mode-provider}} - {:FileName {:provider get-current-file-name - :highlight [colors.light4 bar-bg-col]}} - {:Space {:provider (fn [] "") - :highlight [colors.light0 bar-bg-col]}}]) - (fn make-lsp-diagnostic-provider [kind] (fn [] (let [n (vim.lsp.diagnostic.get_count 0 kind)] (if (= n 0) "" (.. " " n " "))))) -(fn git-branch-provider [] - (let [branch (gl-vcs.get_git_branch)] - (if (= "master" branch) "" branch))) - + +(set galaxyline.section.left + [{:ViMode {:provider + #(let [vim-mode (nvim.fn.mode) + modedata (or (. modes vim-mode) + {:text vim-mode + :colors {:bg colors.neutral_orange :fg colors.dark0}})] + (utils.highlight "GalaxyViMode" modedata.colors) + (.. " " modedata.text " "))}} + + {:FileName {:provider get-current-filepath + :highlight [colors.light4 bar-bg-col]}} + + {:Space {:provider #"" + :highlight [colors.light0 bar-bg-col]}}]) + (set galaxyline.section.right - [{:GitBranch {:provider git-branch-provider - :highlight [colors.light4 bar-bg-col]}} - {:FileType {:provider (fn [] nvim.bo.filetype) + [{:GitBranch {:highlight [colors.light4 bar-bg-col] + :provider + #(let [branch (gl-vcs.get_git_branch)] + (if (= "master" branch) "" branch))}} + + {:FileType {:provider #nvim.bo.filetype :highlight [colors.neutral_aqua bar-bg-col]}} {:DiagnosticInfo {:provider (make-lsp-diagnostic-provider "Info") @@ -90,7 +85,7 @@ {:DiagnosticError {:provider (make-lsp-diagnostic-provider "Error") :highlight [colors.dark1 colors.bright_red] :separator ""}} - {:LineInfo {:provider (fn [] (.. " " (gl-fileinfo.line_column) " ")) + {:LineInfo {:provider #(.. " " (gl-fileinfo.line_column) " ") :highlight "GalaxyViMode" :separator ""}}]) @@ -110,3 +105,5 @@ (set galaxyline.section.right (map-gl-section add-segment-defaults galaxyline.section.right))) + + diff --git a/files/.config/nvim/fnl/utils.fnl b/files/.config/nvim/fnl/utils.fnl index f6de8d6..e8a856b 100644 --- a/files/.config/nvim/fnl/utils.fnl +++ b/files/.config/nvim/fnl/utils.fnl @@ -1,7 +1,8 @@ (module utils {autoload {a aniseed.core fennel aniseed.fennel - nvim aniseed.nvim} + nvim aniseed.nvim + str aniseed.string} require-macros [macros]}) (defn plugin-installed? [name] @@ -92,6 +93,17 @@ (surround-if-present " gui='"colset.gui"'"))))) +(defn shorten-path [path seg-length shorten-after] + "shorten a filepath by truncating the segments to n characters, if the path exceeds a given length" + (let [segments (str.split path "/")] + (if (or (> shorten-after (length path)) + (> 2 (length segments))) + path + (let [init (a.butlast segments) + filename (a.last segments) + shortened-segs (a.map #(string.sub $1 1 seg-length) init)] + (.. (str.join "/" shortened-segs) "/" filename))))) + (defn comp [f g] (fn [...] (f (g ...))))