about summary refs log tree commit diff
path: root/fnl/nvrc/packs
diff options
context:
space:
mode:
authorsefidel <contact@sefidel.net>2022-02-10 00:24:03 +0900
committersefidel <contact@sefidel.net>2022-02-10 00:24:03 +0900
commit72d448e384249103748ee83b587c45924e4bc44d (patch)
tree2aa05a6aaf8c7aa37a8c278fd2fede6e62ff2218 /fnl/nvrc/packs
downloadnvimrc-72d448e384249103748ee83b587c45924e4bc44d.tar.gz
nvimrc-72d448e384249103748ee83b587c45924e4bc44d.zip
Initial commit
Diffstat (limited to 'fnl/nvrc/packs')
-rw-r--r--fnl/nvrc/packs/blankline.fnl11
-rw-r--r--fnl/nvrc/packs/cmp.fnl56
-rw-r--r--fnl/nvrc/packs/feline.fnl144
-rw-r--r--fnl/nvrc/packs/gitsigns.fnl7
-rw-r--r--fnl/nvrc/packs/lsp_signature.fnl15
-rw-r--r--fnl/nvrc/packs/lspconfig.fnl50
-rw-r--r--fnl/nvrc/packs/nvimtree.fnl44
-rw-r--r--fnl/nvrc/packs/telescope.fnl49
-rw-r--r--fnl/nvrc/packs/treesitter.fnl29
9 files changed, 405 insertions, 0 deletions
diff --git a/fnl/nvrc/packs/blankline.fnl b/fnl/nvrc/packs/blankline.fnl
new file mode 100644
index 0000000..3139174
--- /dev/null
+++ b/fnl/nvrc/packs/blankline.fnl
@@ -0,0 +1,11 @@
+(local {: setup} (require :indent_blankline))
+
+(setup {:indentLine_enabled 1
+        :char "▏"
+        :filetype_exclude {:help :terminal
+                           :packer :lspinfo
+                           :TelescopePrompt :TelescopeResults
+                           :lsp-installer ""}
+        :buftype_exclude {1 :terminal}
+        :show_trailing_blankline_indent false
+        :show_first_indent_level false})
diff --git a/fnl/nvrc/packs/cmp.fnl b/fnl/nvrc/packs/cmp.fnl
new file mode 100644
index 0000000..3b70af5
--- /dev/null
+++ b/fnl/nvrc/packs/cmp.fnl
@@ -0,0 +1,56 @@
+(import-macros {: set!} :nvrc.macro.opt)
+(local cmp (require :cmp))
+
+(set! completeopt "menuone,noselect")
+
+(local icons {:Text "(t)"
+              :Method "(m)"
+              :Function "(f)"
+              :Constructor "(cs)"
+              :Field "(s)"
+              :Variable "(v)"
+              :Class "(c)"
+              :Interface "(i)"
+              :Module "(m)"
+              :Property "(p)"
+              :Unit "(u)"
+              :Value "(v)"
+              :Enum "(e)"
+              :Keyword "(k)"
+              :Snippet "(sn)"
+              :Color "(co)"
+              :File "(fi)"
+              :Reference "(r)"
+              :Folder "(fl)"
+              :EnumMember "(em)"
+              :Constant "(cn)"
+              :Struct "(s)"
+              :Event "(ev)"
+              :Operator "(op)"
+              :TypeParameter "(tp)"})
+
+(cmp.setup {
+            :formatting {:format (fn [entry vim-item]
+                                   (set vim-item.kind
+                                        (string.format "%s %s"
+                                                       (. icons vim-item.kind)
+                                                       vim-item.kind))
+                                   (set vim-item.menu
+                                        (. {:nvim_lsp "[LSP]"}
+                                           entry.source.name))
+                                   vim-item)}
+            :mapping {:<C-p> (cmp.mapping.select_prev_item)
+                      :<C-n> (cmp.mapping.select_next_item)
+                      :<C-d> (cmp.mapping.scroll_docs (- 4))
+                      :<C-f> (cmp.mapping.scroll_docs 4)
+                      :<C-Space> (cmp.mapping.complete)
+                      :<C-e> (cmp.mapping.close)
+                      :<CR> (cmp.mapping.confirm {:behavior cmp.ConfirmBehavior.Replace
+                                                  :select true})
+                      :Tab (fn [fallback]
+                             (if (cmp.visible) (cmp.select_next_item)"")
+                                 (fallback))
+                      :<S-Tab> (fn [fallback]
+                                 (if (cmp.visible) (cmp.select_next_item)"")
+                                 (fallback))}
+            :sources {1 {:name :nvim_lsp}}})
diff --git a/fnl/nvrc/packs/feline.fnl b/fnl/nvrc/packs/feline.fnl
new file mode 100644
index 0000000..4953a7d
--- /dev/null
+++ b/fnl/nvrc/packs/feline.fnl
@@ -0,0 +1,144 @@
+(local feline (require :feline))
+(local lsp (require :feline.providers.lsp))
+(local lsp_severity vim.diagnostic.severity)
+(local vi_mode (require :feline.providers.vi_mode))
+(local git (require :feline.providers.git))
+
+(local colors (require :nvrc.colors))
+(local utils (require :nvrc.utils))
+
+(local vi_mode_colors {:NORMAL (. colors :green)
+                       :INSERT (. colors :red)
+                       :VISUAL (. colors :yellow)
+                       :OP (. colors :green)
+                       :BLOCK (. colors :skyblue)
+                       :REPLACE (. colors :violet)
+                       :V-REPLACE (. colors :violet)
+                       :ENTER (. colors :skyblue)
+                       :MORE (. colors :skyblue)
+                       :SELECT (. colors :orange)
+                       :COMMAND (. colors :green)
+                       :SHELL (. colors :green)
+                       :TERM (. colors :green)
+                       :NONE (. colors :yellow)})
+
+(local modules {:pad {:provider "▊ " :hl {:fg (. colors :skyblue)}}
+                :current_position {:provider :position
+                                   :left_sep " "
+                                   :right_sep {1 " "
+                                               2 {:str :vertical_bar_thin
+                                                  :hl {:fg :fg :bg :bg}}}}
+                :vi_mode {:provider :vi_mode
+                          :icon ""
+                          :right_sep " "
+                          :hl (fn []
+                                {:name (vi_mode.get_mode_highlight_name)
+                                 :fg (vi_mode.get_mode_color)})}
+                :file {:info {:provider {:name :file_info
+                                         :opts {:file_modified_icon "[+]"
+                                                :file_readonly_icon "!w "}}
+                              :icon ""
+                              :right_sep " "
+                              :hl {:fg (. colors :orange) :style :bold}}
+                       :encoding {:provider :file_encoding
+                                  :icon ""
+                                  :right_sep " "
+                                  :hl {:fg (. colors :magenta) :style :bold}}
+                       :type {:provider :file_type
+                              :icon ""
+                              :right_sep " "
+                              :hl {:fg (. colors :magenta) :style :bold}}
+                       :size {:provider :file_size
+                              :right_sep {1 " "
+                                          2 {:str :vertical_bar_thin
+                                             :hl {:fg :fg :bg :bg}}}}}
+                :line_percentage {:provider :line_percentage
+                                  :right_sep " "
+                                  :hl {:style :bold}}
+                :scroll_bar {:provider :scroll_bar
+                             :right_sep " "
+                             :hl {:fg (. colors :skyblue) :style :bold}}
+                :lsp {:name {:provider :lsp_client-names
+                             :icon ""
+                             :right_sep " "
+                             :hl {:fg (. colors :yellow)}}
+                      :load_fidget {:provider #(utils.lsp_fidget)
+                                    :enabled #(utils.will_it_fit 80)
+                                    :hl {:fg (. colors :green)}}
+                      :diag_err {:provider :diagnostic_errors
+                                 :enabled #(lsp.diagnostics_exist lsp_severity.ERROR)
+                                 :left_sep " "
+                                 :icon :E
+                                 :hl {:fg (. colors :red)}}
+                      :diag_warn {:provider :diagnostic_warnings
+                                  :enabled #(lsp.diagnostics_exist lsp_severity.WARN)
+                                  :left_sep " "
+                                  :icon :W
+                                  :hl {:fg (. colors :yellow)}}
+                      :diag_info {:provider :diagnostic_info
+                                  :enabled #(lsp.diagnostics_exist lsp_severity.INFO)
+                                  :left_sep " "
+                                  :icon :I
+                                  :hl {:fg (. colors :skyblue)}}
+                      :diag_hint {:provider :diagnostic_hints
+                                  :enabled #(lsp.diagnostics_exist lsp_severity.HINT)
+                                  :left_sep " "
+                                  :icon :H
+                                  :hl {:fg (. colors :white)}}}
+                :git {:branch {:provider :git_branch
+                               :enabled #(git.git_info_exists)
+                               :icon "*"
+                               :right_sep " "
+                               :hl {:fg (. colors :violet) :style :bold}}
+                      :add {:provider :git_diff_added
+                            :enabled #(git.git_info_exists)
+                            :icon "+"
+                            :right_sep " "
+                            :hl {:fg (. colors :green)}}
+                      :change {:provider :git_diff_changed
+                               :enabled #(git.git_info_exists)
+                               :icon "~"
+                               :right_sep " "
+                               :hl {:fg (. colors :orange)}}
+                      :remove {:provider :git_diff_removed
+                               :enabled #(git.git_info_exists)
+                               :icon "-"
+                               :right_sep " "
+                               :hl {:fg (. colors :red)}}}})
+
+(local comps {:left {:active [(. modules :pad)
+                              (. modules :vi_mode)
+                              (. modules :file :info)
+                              (. modules :file :size)
+                              (. modules :current_position)
+                              (. modules :lsp :diag_err)
+                              (. modules :lsp :diag_warn)
+                              (. modules :lsp :diag_info)
+                              (. modules :lsp :diag_hint)]
+                     :inactive []}
+              :middle {:active [(. modules :lsp :load_fidget)]
+                       :inactive []}
+              :right {:active [(. modules :git :branch)
+                               (. modules :git :add)
+                               (. modules :git :change)
+                               (. modules :git :remove)
+                               (. modules :file :encoding)
+                               (. modules :file :type)
+                               (. modules :line_percentage)
+                               (. modules :scroll_bar)]
+                      :inactive []}})
+
+(local components
+       {:active [comps.left.active comps.middle.active comps.right.active]
+        :inactive [comps.left.inactive comps.middle.inactive comps.right.inactive]})
+
+(local properties
+       {:force_inactive {:filetypes [:NvimTree :packer]
+                         :buftypes [:terminal :packer]}})
+
+(feline.setup {:theme colors
+               :default_bg (. colors :bg)
+               :default_fg (. colors :fg)
+               : components
+               : properties
+               : vi_mode_colors})
diff --git a/fnl/nvrc/packs/gitsigns.fnl b/fnl/nvrc/packs/gitsigns.fnl
new file mode 100644
index 0000000..fe500a8
--- /dev/null
+++ b/fnl/nvrc/packs/gitsigns.fnl
@@ -0,0 +1,7 @@
+(local {: setup} (require :gitsigns))
+
+(setup {:signs {:add {:hl :DiffAdd :text "│" :numhl :GitSignsAddNr}
+                :change {:hl :DiffChange :text "│" :numhl :GitSignsChangeNr}
+                :delete {:hl :DiffDelete :text "_" :numhl :GitSignsDeleteNr}
+                :topdelete {:hl :DiffDelete :text "‾" :numhl :GitSignsDeleteNr}
+                :changedelete {:hl :DiffChangeDelete :text "~" :numhl :GitSignsChangeNr}}})
diff --git a/fnl/nvrc/packs/lsp_signature.fnl b/fnl/nvrc/packs/lsp_signature.fnl
new file mode 100644
index 0000000..b14a374
--- /dev/null
+++ b/fnl/nvrc/packs/lsp_signature.fnl
@@ -0,0 +1,15 @@
+(local {: setup} (require :lsp_signature))
+
+(setup {:bind true
+        :doc_lines 0
+        :floating_window true
+        :fix_pos true
+        :hint_enable true
+        :hint_scheme :String
+        :hint_prefix "(i) "
+        :hi_parameter :Search
+        :max_height 22
+        :max_width 120
+        :handler_opts {:border :single}
+        :zindex 200
+        :padding ""})
diff --git a/fnl/nvrc/packs/lspconfig.fnl b/fnl/nvrc/packs/lspconfig.fnl
new file mode 100644
index 0000000..83a4146
--- /dev/null
+++ b/fnl/nvrc/packs/lspconfig.fnl
@@ -0,0 +1,50 @@
+(local lsp (require :lspconfig))
+(local {: highlight} (require :nvrc.macro.color))
+(local {: merge} (require :nvrc.utils))
+(local colors (require :nvrc.colors))
+
+(fn on_attach [client bufnr]
+  (highlight :DiagnosticError {:fg (. colors :red)})
+  (highlight :DiagnosticWarn {:fg (. colors :yellow)})
+  (highlight :DiagnosticInformation {:fg (. colors :green)})
+  (highlight :DiagnosticHint {:fg (. colors :grey)})
+  (if client.resolved_capabilities.document_highlight
+      (do
+        (highlight :LspReferenceRead {:underline true})
+        (highlight :LspReferenceText {:underline true})
+        (highlight :LspReferenceWrite {:underline true})
+        (vim.api.nvim_exec "augroup lsp_document_highlight
+        autocmd! * <buffer>
+        autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
+        augroup END" false))))
+
+(fn better_root_pattern [patterns except-patterns]
+  "match path if one of the given patterns is matched, EXCEPT if one of the except-patterns is matched"
+  (fn [path]
+    (when (not ((lsp.util.root_pattern except-patterns) path))
+      ((lsp.util.root_pattern patterns) path))))
+
+(local default_capabilities (vim.lsp.protocol.make_client_capabilities))
+
+(fn init_lsp [lsp-name ?opts]
+  "initialize a language server with defaults"
+  (let [merged-opts (merge {: on_attach
+                                  :capabilities default_capabilities}
+                                 (or ?opts {}))]
+    ((. lsp lsp-name :setup) merged-opts)))
+
+(tset vim.lsp.handlers :textDocument/publishDiagnostics
+      (vim.lsp.with vim.lsp.diagnostic.on_publish_diagnostics
+                    {:update_in_insert false
+                     :virtual_text {:prefix "-"}
+                     :signs false}))
+
+(init_lsp :ccls)
+(init_lsp :hls)
+(init_lsp :rust_analyzer)
+
+(vim.cmd "highlight link LspSemantic_type Include")
+(vim.cmd "highlight link LspSemantic_function Identifier")
+(vim.cmd "highlight link LspSemantic_struct Number")
+(vim.cmd "highlight LspSemantic_variable guifg=gray")
+(vim.cmd "highlight link LspSemantic_keyword Structure")
diff --git a/fnl/nvrc/packs/nvimtree.fnl b/fnl/nvrc/packs/nvimtree.fnl
new file mode 100644
index 0000000..83326ea
--- /dev/null
+++ b/fnl/nvrc/packs/nvimtree.fnl
@@ -0,0 +1,44 @@
+(import-macros {: setv!} :nvrc.macro.set)
+(local {: setup} (require :nvim-tree))
+
+(setv! nvim_tree_add_trailing 0)
+(setv! nvim_tree_git_hl 1)
+(setv! nvim_tree_highlight_opened_files 0)
+(setv! nvim_tree_indent_markers 1)
+(setv! nvim_tree_quit_on_open 0)
+(setv! nvim_tree_root_folder_modifier
+      (table.concat {1 ":t:gs?$?/.." 2 (string.rep " " 1000) 3 "?:gs?^??"}))
+(setv! nvim_tree_window_picker_exclude
+      {:filetype {1 :notify 2 :packer 3 :qf} :buftype {1 :terminal}})
+
+(setv! nvim_tree_show_icons {:folders 0 :files 0 :git 0 :folder_arrows 0})
+
+; Nvimtree still shows folder icon despite folders being disabled
+; Maybe the nvim_tree_show_icons option isn't really working?
+(setv! nvim_tree_symlink_arrow " -> ")
+(setv! nvim_tree_icons {:default ""
+                       :symlink "~"
+                       :git {:deleted :x
+                             :ignored "?"
+                             :renamed "->"
+                             :staged "*"
+                             :unmerged "!"
+                             :unstaged "!"
+                             :untracked "!"}
+                       :folder {:default "+"
+                                :empty "?"
+                                :empty_open "-"
+                                :open "-"
+                                :symlink "~"
+                                :symlink_open "~-"}})
+
+(setup {:filters {:dotfiles false}
+        :disable_netrw true
+        :hijack_netrw true
+        :auto_close false
+        :open_on_tab false
+        :hijack_cursor true
+        :update_cwd true
+        :update_focused_file {:enable true :update_cwd false}
+        :view {:allow_resize true :side :left :width 25 :hide_root_folder true}
+        :git {:enable false :ignore false}})
diff --git a/fnl/nvrc/packs/telescope.fnl b/fnl/nvrc/packs/telescope.fnl
new file mode 100644
index 0000000..9f9eb0f
--- /dev/null
+++ b/fnl/nvrc/packs/telescope.fnl
@@ -0,0 +1,49 @@
+(local telescope (require :telescope))
+
+(telescope.setup {:defaults {:vimgrep_arguments {1 :rg
+                                                 2 :--color=never
+                                                 3 :--no-heading
+                                                 4 :--with-filename
+                                                 5 :--line-number
+                                                 6 :--column
+                                                 7 :--smart-case}
+                             :prompt_prefix "Search: "
+                             :selection_caret "  "
+                             :entry_prefix "  "
+                             :initial_mode :insert
+                             :selection_strategy :reset
+                             :sorting_strategy :ascending
+                             :layout_strategy :horizontal
+                             :layout_config {:horizontal {:prompt_position :top
+                                                          :preview_width 0.55
+                                                          :results_width 0.8}
+                                             :vertical {:mirror false}
+                                             :width 0.87
+                                             :height 0.8
+                                             :preview_cutoff 120}
+                             :file_sorter (. (require :telescope.sorters)
+                                             :get_fuzzy_file)
+                             :file_ignore_patterns {1 :node_modules}
+                             :generic_sorter (. (require :telescope.sorters)
+                                                :get_generic_fuzzy_sorter)
+                             :path_display {1 :truncate}
+                             :winblend 0
+                             :border {}
+                             :borderchars {1 "─"
+                                           2 "│"
+                                           3 "─"
+                                           4 "│"
+                                           5 "╭"
+                                           6 "╮"
+                                           7 "╯"
+                                           8 "╰"}
+                             :use_less false
+                             :set_env {:COLORTERM :truecolor}
+                             :file_previewer (. (require :telescope.previewers)
+                                                :vim_buffer_cat.new)
+                             :grep_previewer (. (require :telescope.previewers)
+                                                :vim_buffer_vimgrep.new)
+                             :qflist_previewer (. (require :telescope.previewers)
+                                                  :vim_buffer_qflist.new)}})
+
+(telescope.load_extension :terms)
diff --git a/fnl/nvrc/packs/treesitter.fnl b/fnl/nvrc/packs/treesitter.fnl
new file mode 100644
index 0000000..6e02ae5
--- /dev/null
+++ b/fnl/nvrc/packs/treesitter.fnl
@@ -0,0 +1,29 @@
+(local {: setup} (require :nvim-treesitter.configs))
+
+(local colors (require :nvrc.colors))
+
+(setup {:ensure_installed [:fennel :lua]
+        :highlight {:enable true}
+        :indent {:enable true}
+        :refactor {:highlight_definitions {:enable true}
+                   :highlight_current_scope {:enable false}
+                   :smart_rename {:enable true
+                                  :keymaps {:smart_rename :<localleader>rn}}
+                   :navigation {:enable true
+                                :keymaps {:goto_definition :<localleader>gd
+                                          :list_definitions :<localleader>ld
+                                          :list_definitions_toc :<localleader>td
+                                          :goto_next_usage :<a-*>
+                                          :goto_previous_usage "<a-#>"}}}
+        :textobjects {:select {:enable true
+                               :lookahead true
+                               :keymaps {:if "@function.inner"
+                                         :af "@function.outer"
+                                         :ic "@class.inner"
+                                         :ac "@class.outer"
+                                         :ia "@parameter.inner"
+                                         :aa "@parameter.outer"}}
+                      :swap {:enable true
+                             :swap_next {:<localleader>> "@parameter.inner"}
+                             :swap_previous {:<localleader>< "@parameter.inner"}}}
+        :matchup {:enable true}})