From 8f1f8082cb4d267c844cf5356c7cd8e8aeff5f4d Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Wed, 10 Aug 2022 15:14:58 -0700 Subject: [PATCH] neovim updates - use vim.o instead of vim.opt - disable hlsearch - add navic in preparation for 0.8 - disable tree-sitter indent because it's awful in Ruby - add parameter text objects via tree-sitter - use typeprof lsp for Ruby --- nvim/fnl/init.fnl | 55 ++++++++++++++++++++++++++--------------------- nvim/fnl/lsp.fnl | 11 +++++++--- 2 files changed, 38 insertions(+), 28 deletions(-) diff --git a/nvim/fnl/init.fnl b/nvim/fnl/init.fnl index 1f6b82e..3d40275 100644 --- a/nvim/fnl/init.fnl +++ b/nvim/fnl/init.fnl @@ -1,26 +1,21 @@ (vim.cmd "colorscheme paramount") -(set vim.opt.foldlevel 1) -(set vim.opt.linebreak true) -(set vim.opt.list true) - -;; fnlfmt: skip -(set vim.opt.listchars {:tab "\\u21e5 " - :trail "\\u2423" - :extends "\\u21c9" - :precedes "\\u21c7" - :nbsp "\\u00b7"}) - -(set vim.opt.number true) -(set vim.opt.showmode false) -(set vim.opt.termguicolors true) -(set vim.opt.virtualedit :block) -(set vim.opt.wildmode "longest:full") +(set vim.o.foldlevel 1) +(set vim.o.linebreak true) +(set vim.o.list true) +(set vim.o.listchars + "tab:\\u21e5 ,trail:\\u2423,extends:\\u21c9,precedes:\\u21c7,nbsp:\\u00b7") + +(set vim.o.number true) +(set vim.o.showmode false) +(set vim.o.termguicolors true) +(set vim.o.virtualedit :block) +(set vim.o.wildmode "longest:full") ;; search -(set vim.opt.gdefault true) -(set vim.opt.ignorecase true) -(set vim.opt.smartcase true) +(set vim.o.gdefault true) +(set vim.o.ignorecase true) +(set vim.o.smartcase true) (set vim.g.mapleader " ") @@ -32,8 +27,9 @@ (vim.keymap.set :n "\\\\" ":write") (vim.keymap.set :i "\\\\" ":write") -;; clear highlight -(vim.keymap.set :n :/ ":nohlsearch") +;; highlight +(set vim.o.hlsearch false) +; (vim.keymap.set :n :/ ":nohlsearch") ;; non-shifted shortcuts for moving the cursor to the start/end of the current line (vim.keymap.set :n :H "^") @@ -90,6 +86,12 @@ (tset palette f :middle [[:NONE :NONE :NONE :NONE]])) (tset vim.g palette-key palette)) +;;; navic + +;; TODO Enable this when 0.8 is released +;; TODO Use fennel for this? +; (set vim.o.winbar "%{%v:lua.require'nvim-navic'.get_location()%}") + ;;; netrw ;; https://github.com/tpope/vim-vinegar/issues/13 @@ -102,7 +104,8 @@ (setup {:ensure_installed [:fennel :lua :ruby :rust :typescript] :sync_install false :highlight {:enable true :additional_vim_regex_highlighting false} - :indent {:enable true} + ;; disabling since this is super annoying in Ruby + ; :indent {:enable true} :incremental_selection {:enable true :keymaps {:init_selection :gnn :node_incremental :grn @@ -115,10 +118,12 @@ :ac "@class.outer" :ic "@class.inner" :ab "@block.outer" - :ib "@block.inner"}}}})) + :ib "@block.inner" + :aa "@parameter.outer" + :ia "@parameter.inner"}}}})) -(set vim.opt.foldmethod :expr) -(set vim.opt.foldexpr "nvim_treesitter#foldexpr()") +(set vim.o.foldmethod :expr) +(set vim.o.foldexpr "nvim_treesitter#foldexpr()") ;;; generate help files diff --git a/nvim/fnl/lsp.fnl b/nvim/fnl/lsp.fnl index 068c565..a3184f9 100644 --- a/nvim/fnl/lsp.fnl +++ b/nvim/fnl/lsp.fnl @@ -38,7 +38,11 @@ (vim.keymap.set :n :rn lsp.buf.rename bufopts) (vim.keymap.set :n :ca lsp.buf.code_action bufopts) (vim.keymap.set :n :gr lsp.buf.references bufopts) - (vim.keymap.set :n :lf lsp.buf.formatting bufopts))) + (vim.keymap.set :n :lf lsp.buf.formatting bufopts)) + (when (not= client.name :efm) + (let [navic (require :nvim-navic) + {: attach} navic] + (attach client bufnr)))) (local prettier (fmt "prettier --stdin-filepath ${INPUT}" true)) (local fennel [(fmt "fnlfmt /dev/stdin" true) @@ -64,9 +68,10 @@ (set client.resolved_capabilities.document_formatting false))) -(let [{: efm : rust_analyzer : tsserver} (require :lspconfig)] +(let [{: efm : rust_analyzer : tsserver : typeprof} (require :lspconfig)] (efm.setup efm-setup) (rust_analyzer.setup {:on_attach on-attach :settings {:rust-analyzer {:checkOnSave {:command :clippy}}}}) - (tsserver.setup {:on_attach tsserver-attach})) + (tsserver.setup {:on_attach tsserver-attach}) + (typeprof.setup {:on_attach on-attach}))