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.

275 lines
6.8 KiB

  1. " vim: set sw=2 et :
  2. " Configure plug.vim
  3. if has('nvim')
  4. let vimautoloaddir='~/.config/nvim/site/autoload'
  5. else
  6. let vimautoloaddir='~/.vim/autoload'
  7. endif
  8. call plug#begin()
  9. " This is taking care of the plugins
  10. Plug 'junegunn/vim-plug'
  11. " Neovim is sensible by default
  12. if !has('nvim')
  13. Plug 'tpope/vim-sensible'
  14. endif
  15. " Editing eye-candy
  16. Plug 'junegunn/goyo.vim'
  17. Plug 'junegunn/limelight.vim'
  18. " Solarized colorscheme
  19. Plug 'altercation/vim-colors-solarized'
  20. " Tmux .conf
  21. Plug 'tmux-plugins/vim-tmux'
  22. " Tmux Focus Events
  23. Plug 'tmux-plugins/vim-tmux-focus-events'
  24. " Automatically detect indentation
  25. Plug 'tpope/vim-sleuth'
  26. if has('nvim')
  27. " Asynchronous make for neovim
  28. Plug 'neomake/neomake'
  29. " Automated code formatter
  30. Plug 'sbdchd/neoformat'
  31. " Popup terminal
  32. Plug 'kassio/neoterm'
  33. " Nice tree view
  34. Plug 'kyazdani42/nvim-tree.lua'
  35. " Icons for the tree view
  36. Plug 'kyazdani42/nvim-web-devicons'
  37. " A buffer bar
  38. Plug 'noib3/nvim-cokeline'
  39. " Better syntax recognition
  40. Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
  41. " Mason is now preferred over LSP Installer
  42. Plug 'williamboman/mason.nvim'
  43. " LSP config
  44. Plug 'neovim/nvim-lspconfig'
  45. Plug 'williamboman/mason-lspconfig.nvim'
  46. " Auto completion
  47. Plug 'hrsh7th/cmp-nvim-lsp'
  48. Plug 'hrsh7th/cmp-nvim-lsp-signature-help'
  49. Plug 'hrsh7th/cmp-buffer'
  50. Plug 'hrsh7th/cmp-path'
  51. Plug 'hrsh7th/cmp-cmdline'
  52. Plug 'hrsh7th/nvim-cmp'
  53. " Snippets
  54. Plug 'hrsh7th/cmp-vsnip'
  55. Plug 'hrsh7th/vim-vsnip'
  56. Plug 'rafamadriz/friendly-snippets'
  57. " Telescope for quick switching
  58. Plug 'nvim-lua/plenary.nvim'
  59. Plug 'nvim-telescope/telescope.nvim'
  60. Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'make' }
  61. " Copliot here
  62. Plug 'github/copilot.vim'
  63. " Nice colours for our NeoVim
  64. Plug 'ishan9299/nvim-solarized-lua'
  65. Plug 'shaunsingh/solarized.nvim'
  66. " Show indent lines
  67. Plug 'lukas-reineke/indent-blankline.nvim'
  68. " Status line
  69. Plug 'feline-nvim/feline.nvim'
  70. " Dim inactive windows
  71. Plug 'sunjon/shade.nvim'
  72. endif
  73. call plug#end()
  74. if has('nvim')
  75. " Add some colors
  76. set termguicolors
  77. colorscheme solarized-high
  78. " When writing a buffer (no delay), and on normal mode changes (after 750ms).
  79. call neomake#configure#automake('nw', 750)
  80. " Call Neomake when writing a buffer (no delay)
  81. let g:neomake_open_list = 2
  82. " Configure Cokeline
  83. lua << EOF
  84. require('cokeline').setup({
  85. show_if_buffers_are_at_least = 2
  86. })
  87. local map = vim.api.nvim_set_keymap
  88. map('n', '<S-Tab>', '<Plug>(cokeline-focus-prev)', { silent = true })
  89. map('n', '<Tab>', '<Plug>(cokeline-focus-next)', { silent = true })
  90. map('n', '<Leader>h', '<Plug>(cokeline-focus-prev)', { silent = true })
  91. map('n', '<Leader>l', '<Plug>(cokeline-focus-next)', { silent = true })
  92. EOF
  93. " Configure completion and LSP
  94. set completeopt=menu,menuone,noselect
  95. autocmd BufWritePre * lua vim.lsp.buf.formatting_sync(nil, 4000)
  96. lua <<EOF
  97. -- Setup nvim-cmp.
  98. local cmp = require'cmp'
  99. cmp.setup({
  100. snippet = {
  101. expand = function(args)
  102. vim.fn["vsnip#anonymous"](args.body)
  103. end,
  104. },
  105. mapping = cmp.mapping.preset.insert({
  106. ['<C-b>'] = cmp.mapping.scroll_docs(-4),
  107. ['<C-f>'] = cmp.mapping.scroll_docs(4),
  108. ['<C-Space>'] = cmp.mapping.complete(),
  109. ['<C-e>'] = cmp.mapping.abort(),
  110. ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
  111. }),
  112. sources = cmp.config.sources({
  113. { name = 'nvim_lsp' },
  114. { name = 'nvim_lsp_signature_help' },
  115. { name = 'vsnip' },
  116. }, {
  117. { name = 'buffer' },
  118. })
  119. })
  120. require("mason").setup({
  121. automatic_installation = true,
  122. })
  123. require("mason-lspconfig").setup()
  124. EOF
  125. " Configure NvimTree
  126. lua << EOF
  127. require('nvim-tree').setup()
  128. EOF
  129. nmap <leader>n :NvimTreeToggle<CR>
  130. " Configure Telescope
  131. lua << EOF
  132. require('telescope').load_extension('fzf')
  133. EOF
  134. " Find files using Telescope command-line sugar.
  135. nnoremap <leader>ff <cmd>Telescope find_files<cr>
  136. nnoremap <leader>fg <cmd>Telescope live_grep<cr>
  137. nnoremap <leader>fb <cmd>Telescope buffers<cr>
  138. nnoremap <leader>fh <cmd>Telescope help_tags<cr>
  139. " Configure tree-sitter with folding
  140. lua <<EOF
  141. if vim.loop.os_uname().sysname == "Darwin" then
  142. require('nvim-treesitter.install').compilers = { os.getenv("HOME")..'/.local/bin/clang-wrapper' }
  143. end
  144. require('nvim-treesitter.configs').setup({
  145. -- One of "all", or a list of languages
  146. ensure_installed = "all",
  147. ignore_install = { "godot_resource", "teal" },
  148. highlight = {
  149. enable = true
  150. },
  151. indent = {
  152. enable = true
  153. },
  154. })
  155. EOF
  156. set foldmethod=expr
  157. set foldexpr=nvim_treesitter#foldexpr()
  158. " Configure feline
  159. lua <<EOF
  160. require('feline').setup()
  161. EOF
  162. " Configure Shade
  163. lua <<EOF
  164. require('shade').setup({
  165. overlay_opacity = 50,
  166. opacity_step = 1,
  167. keys = {
  168. brightness_up = '<C-Up>',
  169. brightness_down = '<C-Down>',
  170. toggle = '<Leader>s',
  171. }
  172. })
  173. EOF
  174. endif
  175. set background=light
  176. " Keep at least 5 lines anove or below the cursor
  177. set scrolloff=5
  178. " use F2 to switch to paste mode
  179. set pastetoggle=<F2>
  180. " Configure Goyo
  181. nmap <leader>] :Goyo<CR>
  182. function! s:goyo_enter()
  183. if exists('$TMUX')
  184. " Hide the status panel and zoom in the current pane
  185. silent !tmux set status off
  186. " This hackery checks whether the pane is zoomed and toggles the status if
  187. " not
  188. silent !tmux list-panes -F '\#F'|grep -q Z || tmux resize-pane -Z
  189. endif
  190. " All eyes on me
  191. Limelight
  192. " Resize after zoom
  193. if !exists("g:goyo_width")
  194. let g:goyo_width=80
  195. endif
  196. if !exists("g:goyo_height")
  197. let g:goyo_height='85%'
  198. endif
  199. execute "Goyo ".g:goyo_width."x".g:goyo_height
  200. set scrolloff=999
  201. endfunction
  202. function! s:goyo_leave()
  203. if exists('$TMUX')
  204. " Show the status panel and zoom out the current pane
  205. silent !tmux set status on
  206. silent !tmux list-panes -F '\#F'|grep -q Z && tmux resize-pane -Z
  207. endif
  208. Limelight!
  209. set scrolloff=5
  210. endfunction
  211. autocmd! User GoyoEnter nested call <SID>goyo_enter()
  212. autocmd! User GoyoLeave nested call <SID>goyo_leave()
  213. " Configure Limelight
  214. let g:limelight_conceal_ctermfg = 245 " Solarized Base1
  215. let g:limelight_conceal_guifg = '#8a8a8a' " Solarized Base1
  216. """
  217. """ Visually indicate long columns
  218. """ Taken from https://www.youtube.com/watch?v=aHm36-na4-4
  219. """
  220. highlight ColorColumn ctermbg=magenta
  221. call matchadd('ColorColumn', '\%81v', 100)
  222. " Prefer two spaces
  223. set shiftwidth=2
  224. set softtabstop=2
  225. " Show me those tabs, BTW
  226. set list
  227. set listchars=trail:~,nbsp:␣,tab:▸\
  228. " Easy moves through wrapped lines
  229. nnoremap j gj
  230. nnoremap k gk
  231. " Work with tmux mouse integration
  232. set mouse=a
  233. if has('nvim')
  234. set undodir=~/.config/nvim/undodir
  235. else
  236. set undodir=~/.vim/undodir
  237. endif
  238. set undofile