This commit is contained in:
elkowar 2021-05-17 16:03:20 +02:00
parent 63d6a211bb
commit 39dae0dca0
No known key found for this signature in database
GPG key ID: E321AD71B1D1F27F
7 changed files with 82 additions and 31 deletions

View file

@ -6,6 +6,25 @@
ts nvim-treesitter}
require-macros [macros]})
(defn pop [text ft]
"Open a popup with the given text and filetype"
(var width 20)
(each [_ line (ipairs text)]
(set width (math.max width (length line))))
(let [bufnr (vim.api.nvim_create_buf false true)]
(vim.api.nvim_buf_set_option bufnr :bufhidden "wipe")
(vim.api.nvim_buf_set_option bufnr :filetype ft)
(vim.api.nvim_buf_set_lines bufnr 0 -1 true text)
(popup.create bufnr {:padding [1 1 1 1] :width width})))
(defn get-current-word []
"Return the word the cursor is currently hovering over"
(let [col (. (vim.api.nvim_win_get_cursor 0) 2)
line (vim.api.nvim_get_current_line)]
(.. (vim.fn.matchstr (line:sub 1 (+ col 1)) "\\k*$")
(string.sub (vim.fn.matchstr (line:sub (+ col 1)) "^\\k*")
2))))
(def helpfiles-path (str.join "/" (a.butlast (str.split vim.o.helpfile "/"))))
(def tags

View file

@ -11,8 +11,6 @@
(macro make-errors-epic [f]
`(xpcall #,f #(a.println (fennel.traceback $1))))
(when (vim.fn.has "termguicolors")
(se termguicolors true))
@ -79,6 +77,9 @@
(vim.cmd "autocmd! TextYankPost * silent! lua vim.highlight.on_yank {higroup=\"IncSearch\", timeout=300}")
; foldend
; Colors ------------------------------------------------------- foldstart

View file

@ -9,7 +9,8 @@
(utils.keymap :i :<C-Space> "compe#complete()" {:expr true})
(utils.keymap :i :<esc> "compe#close('<esc>')" {:expr true})
;(utils.keymap :i :<esc> "compe#close('<esc>')" {:expr true})
(utils.keymap :i :kj "compe#close('<esc>')" {:expr true})
(utils.keymap [:n] :<C-p> "<cmd>Telescope find_files<cr>")

View file

@ -75,7 +75,11 @@
:folke/lsp-trouble.nvim {:mod "plugins.trouble"}
:simrat39/symbols-outline.nvim {:mod "plugins.symbols-outline"}
:neovim/nvim-lspconfig {}
:hrsh7th/nvim-compe {:mod "plugins.compe"}
;:hrsh7th/nvim-compe {:mod "plugins.compe"}
:/home/leon/coding/prs/nvim-compe {:mod "plugins.compe"}
:glepnir/lspsaga.nvim {:mod "plugins.lspsaga"}

View file

@ -1,5 +1,20 @@
(module plugins.compe
{autoload {compe compe}})
{require {compe compe}})
(defn result-formatter [items]
(var max-width 0)
(each [_ item (ipairs items)]
(set item.abbr (-> item.abbr
(string.gsub "~$" "")
(string.gsub " %(.*%)$" "")))
(set max-width (math.max max-width (vim.fn.strwidth item.abbr))))
(each [_ item (ipairs items)]
(let [padding (string.rep " " (- max-width (vim.fn.strwidth item.abbr)))
details (?. item :user_data :compe :completion_item :detail)]
(when details
(set item.abbr (.. item.abbr padding " " details)))))
items)
(compe.setup
{:enabled true
@ -14,6 +29,7 @@
:max_kind_width 100
:max_menu_width 100
:documentation true
:formatting_functions {:nvim_lsp {:results result-formatter}}
:source {:path true
:buffer true
:calc true

View file

@ -11,8 +11,6 @@
require-macros [macros]})
(local modes
{:n {:text "NORMAL" :color colors.neutral_aqua}
:i {:text "INSERT" :color colors.neutral_yellow}
@ -65,8 +63,8 @@
(defn lsp-progress-provider []
(let [msgs (vim.lsp.util.get_progress_messages)
s (icollect [_ msg (ipairs msgs)]
(when msg.message
(.. msg.title " " msg.message)))]
(when msg.message
(.. msg.title " " msg.message)))]
(or-empty (str.join " | " s))))

View file

@ -1,14 +1,14 @@
(module plugins.lsp
{require {a aniseed.core
lsp lspconfig
lsp-configs lspconfig.configs
utils utils}
{require {a aniseed.core
lsp lspconfig
lsp-configs lspconfig.configs
utils utils}
require-macros [macros]})
require-macros [macros]})
(fn on_attach [client bufnr]
(pkg lsp_signature.nvim [lsp_signature (require "lsp_signature")]
(lsp_signature.on_attach))
(lsp_signature.on_attach))
(if client.resolved_capabilities.document_highlight
(do
@ -16,11 +16,11 @@
(utils.highlight "LspReferenceText" {:gui "underline"})
(utils.highlight "LspReferenceWrite" {:gui "underline"})
(vim.api.nvim_exec
"augroup lsp_document_highlight
autocmd! * <buffer>
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
augroup END"
"augroup lsp_document_highlight
autocmd! * <buffer>
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
augroup END"
false))))
@ -37,17 +37,17 @@
(let [merged-opts (a.merge {:on_attach on_attach} (or ?opts {}))]
((. lsp lsp-name :setup) merged-opts)))
; Added capabilities for rust-analyzer with nvim-compe
(let [capabilities (vim.lsp.protocol.make_client_capabilities)]
(set capabilities.textDocument.completion.completionItem.snippetSupport true)
(set capabilities.textDocument.completion.completionItem.resolveSupport
{:properties ["documentation" "detail" "additionalTextEdits"]})
{:properties ["documentation" "detail" "additionalTextEdits"]})
(init-lsp :rust_analyzer {:capabilities capabilities}))
(init-lsp :tsserver {:root_dir (lsp.util.root_pattern "package.json")})
(init-lsp :jsonls {:commands {:Format [ #(vim.lsp.buf.range_formatting [] [0 0] [(vim.fn.line "$") 0])]}})
(init-lsp :denols {:root_dir (better_root_pattern [".git"] ["package.json"])})
(init-lsp :hls {:settings {:languageServerHaskell {:formattingProvider "stylish-haskell"}}})
(init-lsp :tsserver {:root_dir (lsp.util.root_pattern "package.json")})
(init-lsp :jsonls {:commands {:Format [ #(vim.lsp.buf.range_formatting [] [0 0] [(vim.fn.line "$") 0])]}})
(init-lsp :denols {:root_dir (better_root_pattern [".git"] ["package.json"])})
(init-lsp :hls {:settings {:languageServerHaskell {:formattingProvider "stylish-haskell"}}})
(init-lsp :ocamllsp)
(init-lsp :vimls)
(init-lsp :bashls)
@ -56,13 +56,25 @@
(init-lsp :html)
(init-lsp :cssls)
(let [rust-tools (require "rust-tools")]
(rust-tools.setup {:tools {:inlay_hints {:show_parameter_hints false}}}))
(let [sumneko_root_path (.. vim.env.HOME "/.local/share/lua-language-server")
sumneko_binary (.. sumneko_root_path "/bin/Linux/lua-language-server")]
(init-lsp
:sumneko_lua
{:cmd [sumneko_binary "-E" (.. sumneko_root_path "/main.lua")]
:settings {:Lua {:runtime {:version "LuaJIT"
:path (vim.split package.path ";")}
:diagnostics {:globals ["vim"]}
:workspace {:library {(vim.fn.expand "$VIMRUNTIME/lua") true
(vim.fn.expand "$VIMRUNTIME/lua/vim/lsp") true}}
:telemetry false}}}))
;(lsp.vimls.setup { :on_attach on_attach})
(se signcolumn "yes")
;(let [rust-tools (require "rust-tools")]
;(rust-tools.setup {:tools {:inlay_hints {:show_parameter_hints false}}}))
; vim:foldmarker=<<<<<,>>>>>
; vim:foldmarker=<<<<<,>>>>>