]> git.armaanb.net Git - dotfiles.git/blob - .config/nvim/init.lua
f06885157ea2cd9ba8aab487afffe96dfa379ac5
[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         'sheerun/vim-polyglot';          -- Language pack
30         'tpope/vim-commentary';          -- Easily comment
31         'tpope/vim-rsi';                 -- Readline bindings
32         'tpope/vim-sensible';            -- Sensible defaults
33         'tpope/vim-speeddating';         -- Modify dates with C-a, C-x
34         'tpope/vim-surround';            -- Easily modify sorrounding characters
35 }
36
37 -- Colorscheme
38 vim.opt.termguicolors = true
39 vim.g.colors_name = 'hima'
40
41 -- Easier split movement
42 map('n', '<C-h>', '<C-w><C-h>', opts)
43 map('n', '<C-j>', '<C-w><C-j>', opts)
44 map('n', '<C-k>', '<C-w><C-k>', opts)
45 map('n', '<C-l>', '<C-w><C-l>', opts)
46
47 -- Clear search highlighting
48 map('n', '<C-c>', ':noh<CR>', opts)
49
50 -- Completion
51 vim.opt.completeopt = vim.opt.completeopt + 'menuone'
52 vim.opt.completeopt = vim.opt.completeopt - 'preview'
53 vim.opt.shortmess = vim.opt.shortmess + 'c'
54
55 -- LSP
56 local lspconfig = require('lspconfig')
57
58 local on_attach = function(client, bufnr)
59         -- Shorthand
60         local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr,
61                 ...) end
62         local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr,
63                 ...) end
64
65         -- Use omnifunc for completion
66         buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
67
68         -- Keybindings
69         buf_set_keymap('n', 'gD',
70                 '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
71         buf_set_keymap('n', 'gd',
72                 '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
73         buf_set_keymap('n', 'gr',
74                 '<cmd>lua vim.lsp.buf.references()<CR>', opts)
75         buf_set_keymap('n', 'K',
76                 '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
77         buf_set_keymap('n', '<space>rn',
78                 '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
79         buf_set_keymap('n', '[d',
80                 '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
81         buf_set_keymap('n', ']d',
82                 '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
83 end
84
85 -- Add servers
86 local servers = {
87         'clangd'
88 }
89
90 for _, server in ipairs(servers) do
91         lspconfig[server].setup {on_attach = on_attach}
92 end
93
94 vim.opt.signcolumn = 'no'