]> git.armaanb.net Git - dotfiles.git/blob - .config/nvim/init.lua
nvim: speed up
[dotfiles.git] / .config / nvim / init.lua
1 local map = vim.api.nvim_set_keymap
2 local opts = { noremap=true, silent=true }
3
4 -- General settings
5 vim.opt.mouse = 'a'
6 vim.opt.undofile = true
7 vim.opt.textwidth = 80
8 map('', 'Q', '<nop>', opts)
9 vim.g.mapleader = ' '
10
11 -- Polyglot
12 vim.g.polyglot_disabled = {'sensible'}
13
14 -- Plugins
15 local install_path = vim.fn.stdpath('data') .. '/site/pack/paqs/start/paq-nvim'
16
17 if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
18         vim.fn.system({'git', 'clone', '--depth=1',
19                 'https://github.com/savq/paq-nvim.git', install_path})
20 end
21
22 require('impatient')
23
24 require('paq') {
25         'ctrlpvim/ctrlp.vim';             -- Fuzzy file finding
26         'editorconfig/editorconfig-vim';  -- Follow editorconfig
27         'folke/lsp-colors.nvim';          -- Add LSP colors to any theme
28         'godlygeek/tabular';              -- Line things up
29         'lewis6991/impatient.nvim';       -- Improve startup time
30         'lifepillar/vim-mucomplete';      -- Simple autocompletion
31         'meain/hima-vim';                 -- Nice color scheme
32         'nathom/filetype.nvim';           -- Faster filetype.vim replacement
33         'neovim/nvim-lspconfig';          -- LSP configurations
34         'norcalli/nvim-colorizer.lua';    -- Highlight css colors
35         'ntpeters/vim-better-whitespace'; -- Highlight and strip whitespace
36         'savq/paq-nvim';                  -- paq manages itself
37         'sheerun/vim-polyglot';           -- Language pack
38         'tpope/vim-commentary';           -- Easily comment
39         'tpope/vim-rsi';                  -- Readline bindings
40         'tpope/vim-sensible';             -- Sensible defaults
41         'tpope/vim-speeddating';          -- Modify dates with C-a, C-x
42         'tpope/vim-surround';             -- Easily modify surrounding chars
43 }
44
45 -- Colorscheme
46 vim.opt.termguicolors = true
47 vim.g.colors_name = 'hima'
48
49 -- Easier split movement
50 map('n', '<C-h>', '<C-w><C-h>', opts)
51 map('n', '<C-j>', '<C-w><C-j>', opts)
52 map('n', '<C-k>', '<C-w><C-k>', opts)
53 map('n', '<C-l>', '<C-w><C-l>', opts)
54
55 -- Clear search highlighting
56 map('n', '<C-c>', ':noh<CR>', opts)
57
58 -- Completion
59 vim.opt.completeopt = vim.opt.completeopt + 'menuone'
60 vim.opt.completeopt = vim.opt.completeopt - 'preview'
61 vim.opt.shortmess = vim.opt.shortmess + 'c'
62
63 -- LSP
64 local lspconfig = require('lspconfig')
65
66 local on_attach = function(client, bufnr)
67         -- Shorthand
68         local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr,
69                 ...) end
70         local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr,
71                 ...) end
72
73         -- Use omnifunc for completion
74         buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
75
76         -- Keybindings
77         buf_set_keymap('n', 'gD',
78                 '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
79         buf_set_keymap('n', 'gd',
80                 '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
81         buf_set_keymap('n', 'gr',
82                 '<cmd>lua vim.lsp.buf.references()<CR>', opts)
83         buf_set_keymap('n', 'K',
84                 '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
85         buf_set_keymap('n', '<leader>rn',
86                 '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
87         buf_set_keymap('n', '[d',
88                 '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
89         buf_set_keymap('n', ']d',
90                 '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
91         buf_set_keymap('n', '<leader>e',
92                 '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
93 end
94
95 -- Add servers
96 local servers = {
97         'clangd'
98 }
99
100 for _, server in ipairs(servers) do
101         lspconfig[server].setup {on_attach = on_attach}
102 end
103
104 vim.opt.signcolumn = 'no'
105
106 -- Jump to files with gf
107 vim.opt.hidden = true
108 vim.opt.path = vim.opt.path + '**'
109
110 -- Disable intro message
111 vim.opt.shortmess = "I"