Some changes

This commit is contained in:
Alexander Rosenberg 2023-01-01 16:18:50 -08:00
parent 271319297d
commit 06142dec66
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730
3 changed files with 118 additions and 56 deletions

View File

@ -32,29 +32,54 @@
{ :clear true })
:pattern ,pattern_table
:callback ,callback })))
;; Utility functions for use!
(lambda create-list-entries [...]
(let [output { :active-entry nil
:entries {} }]
(lambda output.process [self entry]
(var result false)
(when self.active-entry
(if (and (. self :entries self.active-entry :is-first)
(not (list? entry)))
(do (tset self :entries self.active-entry :data entry)
(set self.active-entry nil)
(set result true))
(= (type entry) :string)
(set self.active-entry nil)
(do (table.insert (. self :entries self.active-entry :data) entry)
(tset self :entries self.active-entry :is-first false)
(set result true))))
(when (and (= (type entry) :string) (. self :entries entry))
(assert-compile (not (. self :entries entry :present))
(.. "':" entry "' cannot appear more than once in `use'"))
(set self.active-entry entry)
(tset self :entries entry :present true)
(set result true))
result)
(lambda output.splice-into [self other]
(each [name entry (pairs self.entries)]
(when entry.present
(tset other name entry.data))))
(each [_ val (ipairs [...])]
(tset output :entries val { :present false :is-first true :data `(lambda [])}))
output))
;; Nicer macro for use
;; :config acts like use-package's :init and :config options,
;; taking in the following lisp expressions as its arguments
(lambda use! [repo ...]
(local output [ repo ])
(var last_key nil)
(var config_mode false)
(var has_config false)
(var config_entries (list `lambda []))
(var list_entries (create-list-entries :config :setup
:run))
(each [_ val (ipairs [...])]
(if config_mode
(if (= (type val) :string)
(set config_mode false)
(table.insert config_entries val))
last_key
(do (tset output last_key val)
(set last_key nil))
(= val :config)
(do (set config_mode true)
(set has_config true))
(if last_key
(do (tset output last_key val)
(set last_key nil))
(not (list_entries:process val))
(set last_key val)))
(if has_config
(tset output :config config_entries))
(list_entries:splice-into output)
`(use ,output))
;; Call a plugin's `setup function'

View File

@ -59,33 +59,59 @@
;; fzf (a fuzzy finder)
(use! :ibhagwan/fzf-lua
:cmd :FzfLua
:setup
(bind! :n :<leader>fq "<cmd>FzfLua quickfix<cr>")
(bind! :n :<leader>fr "<cmd>FzfLua registers<cr>")
(bind! :n :<leader>fj "<cmd>FzfLua jumps<cr>")
(bind! :n :<leader>fa "<cmd>FzfLua marks<cr>")
(bind! :n :<leader>fh "<cmd>FzfLua help_tags<cr>")
(bind! :n :<leader>g "<cmd>FzfLua live_grep<cr>")
(bind! :n :<leader>fg "<cmd>FzfLua live_grep<cr>")
(bind! :n :<leader>G "<cmd>FzfLua grep<cr>")
(bind! :n :<leader>fG "<cmd>FzfLua grep<cr>")
(bind! :n :<leader>b "<cmd>FzfLua buffers<cr>")
(bind! :n :gb "<cmd>FzfLua buffers<cr>")
(bind! :n :<leader>fu "<cmd>FzfLua git_status<cr>")
(bind! :n :<leader>fm "<cmd>FzfLua man_pages<cr>")
(bind! :n :<leader>fe "<cmd>FzfLua diagnostics_document<cr>")
(bind! :n :<leader>fE "<cmd>FzfLua diagnostics_workspace<cr>")
(bind! :n :<leader>d "<cmd>FzfLua loclist<cr>")
(bind! :n :<leader>fp "<cmd>FzfLua spell_suggest<cr>")
(bind! :n :<leader>i "<cmd>FzfLua files<cr>")
(bind! :n :z= "<cmd>FzfLua spell_suggest<cr>")
(bind! :n :<leader>ff (fn []
(let [code (os.execute "git rev-parse --is-inside-work-tree >/dev/null 2>&1")]
(if (= code 0)
(vim.cmd "FzfLua git_files")
(vim.cmd "FzfLua files")))))
:config
(let [fzf (require :fzf-lua)]
(fzf.register_ui_select)
(bind! :n :<leader>fq fzf.quickfix)
(bind! :n :<leader>fr fzf.registers)
(bind! :n :<leader>fj fzf.jumps)
(bind! :n :<leader>fa fzf.marks)
(bind! :n :<leader>fh fzf.help_tags)
(bind! :n :<leader>g fzf.live_grep)
(bind! :n :<leader>fg fzf.live_grep)
(bind! :n :<leader>G fzf.grep)
(bind! :n :<leader>fG fzf.grep)
(bind! :n :<leader>b fzf.buffers)
(bind! :n :gb fzf.buffers)
(bind! :n :<leader>fu fzf.git_status)
(bind! :n :<leader>fm fzf.man_pages)
(bind! :n :<leader>fe fzf.diagnostics_document)
(bind! :n :<leader>fE fzf.diagnostics_workspace)
(bind! :n :<leader>d fzf.loclist)
(bind! :n :<leader>fp fzf.spell_suggest)
(bind! :n :<leader>i fzf.files)
(bind! :n :z= fzf.spell_suggest)
(bind! :n :<leader>ff (fn []
(let [code (os.execute "git rev-parse --is-inside-work-tree >/dev/null 2>&1")]
(if (= code 0)
(fzf.git_files)
(fzf.files)))))
;; (bind! :n :<leader>fq fzf.quickfix)
;; (bind! :n :<leader>fr fzf.registers)
;; (bind! :n :<leader>fj fzf.jumps)
;; (bind! :n :<leader>fa fzf.marks)
;; (bind! :n :<leader>fh fzf.help_tags)
;; (bind! :n :<leader>g fzf.live_grep)
;; (bind! :n :<leader>fg fzf.live_grep)
;; (bind! :n :<leader>G fzf.grep)
;; (bind! :n :<leader>fG fzf.grep)
;; (bind! :n :<leader>b fzf.buffers)
;; (bind! :n :gb fzf.buffers)
;; (bind! :n :<leader>fu fzf.git_status)
;; (bind! :n :<leader>fm fzf.man_pages)
;; (bind! :n :<leader>fe fzf.diagnostics_document)
;; (bind! :n :<leader>fE fzf.diagnostics_workspace)
;; (bind! :n :<leader>d fzf.loclist)
;; (bind! :n :<leader>fp fzf.spell_suggest)
;; (bind! :n :<leader>i fzf.files)
;; (bind! :n :z= fzf.spell_suggest)
;; (bind! :n :<leader>ff (fn []
;; (let [code (os.execute "git rev-parse --is-inside-work-tree >/dev/null 2>&1")]
;; (if (= code 0)
;; (fzf.git_files)
;; (fzf.files)))))
(fn jump-or-open-terminal []
"If no terminal buffer exists, create one. Otherwise, open new one."
(var term_count 0)
@ -101,7 +127,8 @@
(vim.cmd.terminal)
(= term_count 1)
(vim.cmd.buffer last_id)
(fzf.buffers { :query "term://" })))
(vim.cmd "FzfLua buffers query=term://")))
;;(fzf.buffers { :query "term://" })))
(bind! :n :<leader>t jump-or-open-terminal)))
;; Nvim surround
@ -170,6 +197,7 @@
;; vlime (lisp environment)
(use! :vlime/vlime
:ft :lisp
:config
(set vim.g.vlime_cl_impl :my_sbcl)
(set vim.g.vlime_address [ "127.0.0.1" 52842 ])
@ -199,13 +227,16 @@
:config
(module-call! :plugin.cmp :configure))
;; does what the name says, lets you pick icons
(use! :ziontee113/icon-picker.nvim
:after :fzf-lua
:config
(setup! :icon-picker
:disable_legacy_commands true)
:cmd [ :IconPickerNormal :IconPickerYank ]
:setup
(bind! :n :<leader>ci "<cmd>IconPickerNormal<cr>")
(bind! :n :<leader>cy "<cmd>IconPickerYank<cr>"))
(bind! :n :<leader>cy "<cmd>IconPickerYank<cr>")
:config
(vim.cmd "PackerLoad fzf-lua")
(setup! :icon-picker
:disable_legacy_commands true))
;; guess style from buffer
(use! :NMAC427/guess-indent.nvim
@ -214,8 +245,7 @@
;; lspconfig
(use! :neovim/nvim-lspconfig
:after [ :cmp-nvim-lsp
:fzf-lua ]
:after :cmp-nvim-lsp
:config
(module-call! :plugin.lsp :configure))

View File

@ -23,15 +23,22 @@
; (bind! :n :gr vim.lsp.buf.references buf)
(bind! :n :<leader>o #(vim.lsp.buf.format { :async true }) buf)
;; Some telescope commands
(let [fzf (require :fzf-lua)]
(bind! :n :gr fzf.lsp_references buf)
(bind! :n :<leader>s fzf.lsp_live_workspace_symbols buf)
(bind! :n :<leader>fs fzf.lsp_live_workspace_symbols buf)
(bind! :n :<leader>fS fzf.lsp_workspace_symbols buf)
(bind! :n :<leader>d fzf.lsp_document_symbols buf)
(bind! :n :<leader>fd fzf.lsp_document_symbols buf)
(bind! :n :<leader>cn fzf.lsp_code_actions buf)))
;; Some fzf commands
(bind! :n :gr "<cmd>FzfLua lsp_references<cr>" buf)
(bind! :n :<leader>s "<cmd>FzfLua lsp_live_workspace_symbols<cr>" buf)
(bind! :n :<leader>fs "<cmd>FzfLua lsp_live_workspace_symbols<cr>" buf)
(bind! :n :<leader>fS "<cmd>FzfLua lsp_workspace_symbols<cr>" buf)
(bind! :n :<leader>d "<cmd>FzfLua lsp_document_symbols<cr>" buf)
(bind! :n :<leader>fd "<cmd>FzfLua lsp_document_symbols<cr>" buf)
(bind! :n :<leader>cn "<cmd>FzfLua lsp_code_actions<cr>" buf))
;; (let [fzf (require :fzf-lua)]
;; (bind! :n :gr fzf.lsp_references buf)
;; (bind! :n :<leader>s fzf.lsp_live_workspace_symbols buf)
;; (bind! :n :<leader>fs fzf.lsp_live_workspace_symbols buf)
;; (bind! :n :<leader>fS fzf.lsp_workspace_symbols buf)
;; (bind! :n :<leader>d fzf.lsp_document_symbols buf)
;; (bind! :n :<leader>fd fzf.lsp_document_symbols buf)
;; (bind! :n :<leader>cn fzf.lsp_code_actions buf)))
(fn get-data-dir [server root]
(let [resolved_path (vim.fn.resolve root)