1
0
Fork 0

nvim: Cleanup config

This commit is contained in:
Daniel Kempkens 2022-09-26 15:54:38 +02:00
parent 383ecccd04
commit e648e4dcbb
Signed by: daniel
SSH key fingerprint: SHA256:Ks/MyhQYcPRQiwMKLAKquWCdCPe3JXlb1WttgnAoSeM
3 changed files with 2 additions and 76 deletions

View file

@ -1,74 +0,0 @@
(let [mod {}
spinner-frames ["⣾" "⣽" "⣻" "⢿" "⡿" "⣟" "⣯" "⣷"]
client-notifications {}]
;; Progress Notifications
;; Based on: https://github.com/rcarriga/nvim-notify/wiki/Usage-Recipes#progress-updates
(fn get-notification-data [client-id token]
(when (= (. client-notifications client-id) nil)
(tset client-notifications client-id {}))
(when (= (. client-notifications client-id token) nil)
(tset client-notifications client-id token {}))
(. client-notifications client-id token))
(fn update-notifcation-spinner [client-id token]
(let [notification-data (get-notification-data client-id token)]
(when notification-data.spinner
(let [new-spinner (% (+ notification-data.spinner 1)
(length spinner-frames))]
(set notification-data.spinner new-spinner)
(set notification-data.notification
(vim.notify nil nil
{:hide_from_history true
:icon (. spinner-frames new-spinner)
:replace notification-data.notification}))
(vim.defer_fn #(update-notifcation-spinner client-id token))))))
(fn format-notifcation-title [title client-name]
(.. client-name (if (> (length title) 0) (.. ": " title) "")))
(fn format-notifcation-message [message percentage]
(.. (if percentage (.. percentage "%\t") "") (if message message "")))
(fn handle-progress [err result ctx]
(let [client-id ctx.client_id
val result.value
kind val.kind
lsp-client (vim.lsp.get_client_by_id client-id)
client-name lsp-client.name
notification-data (get-notification-data client-id result.token)]
(if (= kind :begin)
(let [message (format-notifcation-message val.message val.percentage)]
(set notification-data.notification
(vim.notify message :info
{:title (format-notifcation-title val.title
client-name)
:icon (. spinner-frames 1)
:timeout false
:hide_from_history false}))
(set notification-data.spinner 1)
(update-notifcation-spinner client-id result.token))
(and (= kind :report) notification-data)
(let [message (format-notifcation-message val.message val.percentage)]
(set notification-data.notification
(vim.notify message :info
{:replace notification-data.notification
:hide_from_history false})))
(and (= kind :end) notification-data)
(let [message (if val.message
(format-notifcation-message val.message)
:Complete)]
(set notification-data.notification
(vim.notify message :info
{:icon ""
:replace notification-data.notification
:timeout 3000}))
(set notification-data.spinner nil)))))
;; Public Interface
(fn mod.register-progress-handler []
(tset vim.lsp.handlers :$/progress handle-progress))
mod)

View file

@ -1,7 +1,6 @@
(let [lsp (require :lspconfig)
cmp (require :cmp_nvim_lsp)
navic (require :nvim-navic)
nifoc-lsp (require :nifoc.lsp)
diagnostic (require :nifoc.diagnostic)
formatting (require :nifoc.formatting)]
(fn custom-attach [client bufnr]
@ -19,7 +18,6 @@
(vim.lsp.with vim.lsp.handlers.hover {:border :rounded}))
(tset vim.lsp.handlers :textDocument/signatureHelp
(vim.lsp.with vim.lsp.handlers.signature_help {:border :rounded}))
(nifoc-lsp.register-progress-handler)
;; Servers
(let [default-capabilities (vim.lsp.protocol.make_client_capabilities)
capabilities (cmp.update_capabilities default-capabilities)

View file

@ -1,6 +1,8 @@
(let [osc52 (require :osc52)
uname (vim.loop.os_uname)
clip-name :nifocClipboard]
(osc52.setup {:silent true})
(fn copy [lines _]
(-> lines
(table.concat "\n")