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