galaxyline

This commit is contained in:
elkowar 2021-04-03 19:43:27 +02:00
parent b8f7b2909e
commit c45855021f
2 changed files with 101 additions and 21 deletions

View file

@ -19,15 +19,15 @@
(local compe (require "compe")) (local compe (require "compe"))
;(fn on_attach [client bufnr] (fn on_attach [client bufnr]
;(if client.resolved_capabilities.document_highlight (if client.resolved_capabilities.document_highlight
;(nvim.api.nvim_exec (nvim.api.nvim_exec
;"hi LspReferenceRead cterm=bold ctermbg=red guibg='#8ec07c' guifg='#282828' hi LspReferenceText cterm=bold ctermbg=red guibg='#8ec07c' guifg='#282828' hi LspReferenceWrite cterm=bold ctermbg=red guibg='#8ec07c' guifg='#282828' "hi LspReferenceRead cterm=bold ctermbg=red guibg='#8ec07c' guifg='#282828' hi LspReferenceText cterm=bold ctermbg=red guibg='#8ec07c' guifg='#282828' hi LspReferenceWrite cterm=bold ctermbg=red guibg='#8ec07c' guifg='#282828'
;augroup lsp_document_highlight augroup lsp_document_highlight
;autocmd! * <buffer> autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight() autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references() autocmd! * <buffer> autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight() autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
;augroup END " false))) augroup END " false)))
(fn on_attach [client bufnr] (print "hi")) ;(fn on_attach [client bufnr] (print "hi"))
(lsp.rust_analyzer.setup { :on_attach on_attach}) (lsp.rust_analyzer.setup { :on_attach on_attach})
@ -72,12 +72,16 @@
:vsplit "v" :vsplit "v"
:split "b" :split "b"
:scroll_up "<C-u>" :scroll_up "<C-u>"
:scroll_down "<C-d>"}} :scroll_down "<C-d>"}})
(local galaxyline (require "galaxyline")) (local galaxyline (require "galaxyline"))
(local colors (utils.colors))) (local gl-condition (require "galaxyline.condition"))
(local gl-fileinfo (require "galaxyline.provider_fileinfo"))
(local gl-diagnostic (require "galaxyline.provider_diagnostic"))
(local gl-vcs (require "galaxyline.provider_vcs"))
(local colors (utils.colors))
(local modes (local modes
{ :n { :text "NORMAL" :colors { :bg colors.neutral_aqua :fg colors.dark0}} { :n { :text "NORMAL" :colors { :bg colors.neutral_aqua :fg colors.dark0}}
@ -101,17 +105,89 @@
(fn viModeProvider [] (fn get-mode-data []
(let [modedata (or (. modes (nvim.fn.mode)) (or (. modes (nvim.fn.mode))
{ :text (nvim.fn.mode) :colors {:bg colors.neutral_orange :fg colors.dark0}})] { :text (nvim.fn.mode)
:colors {:bg colors.neutral_orange :fg colors.dark0}}))
(fn buf-empty? []
(= 1 (nvim.fn.empty (nvim.fn.expand "%:t"))))
(fn checkwidth []
(and (< 35 (/ (nvim.fn.winwidth 0) 2))
(not buf-empty?)))
(fn file-readonly-or-help? []
(and nvim.bo.readonly (~= nvim.bo.filetype "help")))
(fn get-current-file-name []
(let [file (nvim.fn.expand "%:t")]
(if
(= 1 (nvim.fn.empty file)) ""
(file-readonly-or-help?) (.. "RO " file)
(and nvim.bo.modifiable nvim.bo.modified) (.. file " ")
file)))
(utils.highlight "StatusLine" {:bg colors.dark1 :fg colors.light0})
(set galaxyline.short_line_list ["dbui" "diff" "peekaboo" "undotree" "vista" "vista_markdown"])
(set galaxyline.section.left
[ { :ViMode { :provider
(fn []
(let [modedata (get-mode-data)]
(utils.highlight "GalaxyViMode" modedata.colors) (utils.highlight "GalaxyViMode" modedata.colors)
modedata.text)) (.. " " modedata.text " ")))}}
{ :FileName { :provider get-current-file-name
:highlight [colors.light4 colors.dark1]}}
{ :Space { :provider (fn [] "")
:highlight [colors.light0 colors.dark1]}}])
(tset galaxyline.section.left 1 (fn provider-lsp-diag [kind]
{ :ViMode { :provider viModeProvider :icon " "}}) (fn []
(let [n (vim.lsp.diagnostic.get_count 0 kind)]
(if
(= n 0) ""
(.. " " n " ")))))
(tset galaxyline.section.left 2 (set galaxyline.section.right
{ :FileSize { :provider "FileSize"}}) [ { :GitBranch { :provider (fn []
(let [branch (gl-vcs.get_git_branch)]
(if (= "master" branch) "" branch)))
:highlight [colors.light4 colors.dark1]}}
{ :FileType { :provider (fn [] nvim.bo.filetype)
:highlight [colors.neutral_aqua colors.dark1]}}
{ :DiagnosticInfo { :provider (provider-lsp-diag "Info")
:highlight [colors.dark1 colors.neutral_blue]}}
{ :DiagnosticWarn { :provider (provider-lsp-diag "Warning")
:highlight [colors.dark1 colors.neutral_yellow]
:separator ""}}
{ :DiagnosticError { :provider (provider-lsp-diag "Error")
:highlight [colors.dark1 colors.bright_red]
:separator ""}}
{ :LineInfo { :provider (fn [] (.. " " (gl-fileinfo.line_column) " "))
:highlight "GalaxyViMode"
:separator ""}}])
(do
(fn add-segment-defaults [data]
(a.merge { :highlight [colors.light0 colors.dark1]
:separator " "
:separator_highlight "StatusLine"}
data))
(fn map-gl-section [f section]
(icollect [_ elem (ipairs section)]
(collect [k v (pairs elem)] (values k (f v)))))
(set galaxyline.section.left (map-gl-section add-segment-defaults galaxyline.section.left))
(set galaxyline.section.right (map-gl-section add-segment-defaults galaxyline.section.right)))

View file

@ -53,4 +53,8 @@
(defn highlight [group colset] (defn highlight [group colset]
(nvim.command (.. "hi " group " guifg='" colset.fg "' guibg='" colset.bg "'"))) (nvim.command (.. "hi " group " guifg='" colset.fg "' guibg='" colset.bg "' gui=NONE")))
(defn comp [f g ...]
(f (g ...)))