my configs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

226 lines
6.2 KiB

  1. local utils = require("utils")
  2. local set = vim.opt
  3. local map = utils.map
  4. vim.cmd [[runtime system.vim]]
  5. require('plugins')
  6. if vim.api.nvim_eval("has('autocmd')") then
  7. -- Set leader to space
  8. vim.g.mapleader = " "
  9. vim.cmd [[filetype plugin indent on]]
  10. end
  11. if vim.api.nvim_eval("has('syntax')") then
  12. -- Use syntax highlighting
  13. if not vim.g.syntax_on then
  14. vim.cmd [[syntax enable]]
  15. end
  16. -- Use my colorscheme if using the GUI or if we have 256 colors
  17. if vim.api.nvim_eval("has('gui_running') || &t_Co >= 256") then
  18. vim.cmd [[silent! color monokai]]
  19. end
  20. -- If not monokai, then default with dark background
  21. if not vim.g.colors_name then
  22. vim.o.background = "dark"
  23. end
  24. end
  25. -- Use UTF-8 if we can and env LANG didn't tell us not to
  26. if vim.api.nvim_eval("has('multi_byte') && !exists('$LANG') && &encoding ==# 'latin1'") then
  27. set.encoding = "utf-8"
  28. end
  29. -- The all-important default indent settings; filetypes to tweak
  30. set.autoindent = true -- Use indent of previous line on new lines
  31. set.expandtab = true -- Use spaces instead of tabs
  32. set.shiftwidth = 2 -- Indent with two spaces
  33. set.softtabstop = 2 -- Insert two spaces with tab key
  34. set.smartindent = true -- Enable smart-indent
  35. set.smarttab = true -- Enable smart-tabs
  36. set.tabstop = 2
  37. set.cindent = true
  38. -- Let me backspace over pretty much anything
  39. set.backspace = "indent,eol,start"
  40. -- Indent wrapped lines
  41. set.breakindent = true
  42. -- Give me a prompt instead of just rejecting risky :write, :saveas
  43. set.confirm = true
  44. -- Clear default 'comments' value, let the filetype handle it
  45. set.comments = ""
  46. vim.cmd [[
  47. " Add completion options
  48. if exists('+completeopt')
  49. set completeopt+=noinsert
  50. set completeopt+=longest " Insert longest common substring
  51. set completeopt+=menuone " Show the menu even if only one match
  52. set completeopt+=noselect " Show the menu even if only one match
  53. else
  54. set completeopt=noinsert,longest,menuone,noselect
  55. endif
  56. " Don't wait for a key after Escape in insert mode
  57. " In vim-tiny but not NeoVim, so just suppress errors
  58. silent! set noesckeys
  59. " Fold based on indent, but only when I ask
  60. if has('folding')
  61. set foldlevelstart=99
  62. set foldmethod=indent
  63. endif
  64. " Delete comment leaders when joining lines, if supported
  65. silent! set formatoptions+=j
  66. " If available, use GNU grep niceties for searching
  67. if system('grep --version') =~# '^grep (GNU grep)'
  68. set grepprg=grep\ -HnRs\ --exclude='.git*'
  69. endif
  70. " Don't load GUI menus; set here before GUI starts
  71. if has('gui_running')
  72. set guioptions+=M
  73. set guioptions+=LlRrb
  74. set guioptions-=LlRrb
  75. set guioptions-=T
  76. set guioptions-=m
  77. endif
  78. " Allow buffers to have changes without being displayed
  79. set hidden
  80. " Keep much more command and search history
  81. set history=2000
  82. " Highlight completed searches; clear on reload
  83. set hlsearch
  84. if 1
  85. nohlsearch
  86. endif
  87. ]]
  88. -- Don't assume I'm editing C; let the filetype set this
  89. set.include=""
  90. vim.cmd [[
  91. " Show search matches as I type my pattern
  92. set incsearch
  93. " Don't join lines with two spaces at the end of sentences
  94. set nojoinspaces
  95. " Don't show a statusline if there's only one window
  96. " This is the Vim default, but NeoVim changed it
  97. if &laststatus != 1
  98. set laststatus=1
  99. endif
  100. " Don't redraw the screen during batch execution
  101. set lazyredraw
  102. " Break lines at word boundaries
  103. set linebreak
  104. " Disable command line display of file position
  105. " This is the Vim default, but NeoVim changed it
  106. if &ruler
  107. set noruler
  108. endif
  109. " Show row and column ruler information
  110. set ruler
  111. set colorcolumn=100
  112. " Options for file search with gf/:find
  113. set path-=/usr/include " Let the C/C++ filetypes set that
  114. set path+=** " Search current directory's whole tree
  115. " Prefix wrapped rows with three dots
  116. set showbreak=...
  117. " New windows go below or to the right of a split
  118. set splitbelow
  119. set splitright
  120. " Give me a bit longer to complete mappings
  121. set notimeout
  122. set nottimeout
  123. set timeoutlen=10000
  124. set ttimeoutlen=10000
  125. " No terminal mouse, even if we could
  126. silent! set ttymouse=
  127. " Keep undo files, hopefully in a dedicated directory
  128. if has('persistent_undo')
  129. set undofile
  130. set undodir^=~/.vim/cache/undo//
  131. endif
  132. set undolevels=1000 " Number of undo levels
  133. " Wildmenu settings; see also plugin/wildignore.vim
  134. set wildmenu " Use wildmenu
  135. "set wildmode=list:longest " Tab press completes and lists
  136. silent! set wildignorecase " Case insensitive, if supported
  137. " Let me move beyond buffer text in visual block mode
  138. if exists('+virtualedit')
  139. set virtualedit+=block
  140. endif
  141. ]]
  142. set.diffopt = "filler,iwhite"
  143. set.fileencoding="utf-8"
  144. vim.cmd [[set fillchars+=stl:\ ,stlnc:\ ]]
  145. set.foldcolumn = "1"
  146. set.foldlevel = 0
  147. set.foldmethod = "expr"
  148. set.foldexpr = "nvim_treesitter#foldexpr()"
  149. -- Always case-insensitive
  150. set.ignorecase = true
  151. set.laststatus = 2
  152. -- Break lines at word (requires Wrap lines)
  153. set.linebreak = true
  154. vim.cmd [[
  155. set list lcs=tab:\|\
  156. set noerrorbells vb t_vb=
  157. ]]
  158. set.foldenable = false
  159. -- Show line numbers
  160. set.number = true
  161. set.omnifunc = "syntaxcomplete#Complete"
  162. set.scrolloff = 1
  163. set.showcmd = true
  164. -- Highlight matching brace
  165. set.showmatch = true
  166. -- Enable smart-case search
  167. set.smartcase = true
  168. vim.cmd [[set termencoding=utf-8]]
  169. -- Line wrap (number of cols)
  170. set.textwidth = 100
  171. -- Use visual bell (no beeping)
  172. set.visualbell = true
  173. -- Delete Selected word from whole file
  174. map {'n', '<Leader>s', ':%s/<<C-r><C-w>>//g<Left><Left>'}
  175. -- Stop C-r from being seen as backspace
  176. map {'n', '<BS>', ':TmuxNavigateLeft<cr>'}
  177. -- \R reloads ~/.vimrc
  178. map {'n', '<Bslash>R', ':<C-U>source $MYVIMRC<CR>'}
  179. -- \DEL deletes the current buffer
  180. map {'n', '<Bslash><Delete>', ':bdelete<CR>'}
  181. -- \INS edits a new buffer
  182. map {'n', '<Bslash><Insert>', ':<C-U>enew<CR>'}
  183. -- \/ types :vimgrep for me ready to enter a search pattern
  184. map {'n', '<Bslash>/', ':<C-U>vimgrep /c/ **<S-Left><S-Left><Right>'}
  185. -- \p toggles paste mode
  186. map {'n', '<Bslash>p', ':<C-U>set paste! paste?<CR>'}