]> git.armaanb.net Git - dotfiles.git/blob - .config/nvim/init.lua
nvim: use FZF instead of ctrl-p
[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         'junegunn/fzf';                   -- Fuzzy file finding
26         'junegunn/fzf.vim';               -- Fuzzy file finding
27         'editorconfig/editorconfig-vim';  -- Follow editorconfig
28         'folke/lsp-colors.nvim';          -- Add LSP colors to any theme
29         'godlygeek/tabular';              -- Line things up
30         'lewis6991/impatient.nvim';       -- Improve startup time
31         'lifepillar/vim-mucomplete';      -- Simple autocompletion
32         'meain/hima-vim';                 -- Nice color scheme
33         'nathom/filetype.nvim';           -- Faster filetype.vim replacement
34         'neovim/nvim-lspconfig';          -- LSP configurations
35         'norcalli/nvim-colorizer.lua';    -- Highlight css colors
36         'ntpeters/vim-better-whitespace'; -- Highlight and strip whitespace
37         'savq/paq-nvim';                  -- paq manages itself
38         'sheerun/vim-polyglot';           -- Language pack
39         'tpope/vim-commentary';           -- Easily comment
40         'tpope/vim-rsi';                  -- Readline bindings
41         'tpope/vim-sensible';             -- Sensible defaults
42         'tpope/vim-speeddating';          -- Modify dates with C-a, C-x
43         'tpope/vim-surround';             -- Easily modify surrounding chars
44 }
45
46 -- Colorscheme
47 vim.opt.termguicolors = true
48 vim.g.colors_name = 'hima'
49
50 -- Easier split movement
51 map('n', '<C-h>', '<C-w><C-h>', opts)
52 map('n', '<C-j>', '<C-w><C-j>', opts)
53 map('n', '<C-k>', '<C-w><C-k>', opts)
54 map('n', '<C-l>', '<C-w><C-l>', opts)
55
56 -- Clear search highlighting
57 map('n', '<C-c>', ':noh<CR>', opts)
58
59 -- FZF
60 map('n', '<leader>f', ':Files<CR>', opts)
61 -- TODO: Sharp corners... I can't figure this out
62
63 -- Completion
64 vim.opt.completeopt = vim.opt.completeopt + 'menuone'
65 vim.opt.completeopt = vim.opt.completeopt - 'preview'
66 vim.opt.shortmess = vim.opt.shortmess + 'c'
67
68 -- LSP
69 local lspconfig = require('lspconfig')
70
71 local on_attach = function(client, bufnr)
72         -- Shorthand
73         local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr,
74                 ...) end
75         local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr,
76                 ...) end
77
78         -- Use omnifunc for completion
79         buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
80
81         -- Keybindings
82         buf_set_keymap('n', 'gD',
83                 '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
84         buf_set_keymap('n', 'gd',
85                 '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
86         buf_set_keymap('n', 'gr',
87                 '<cmd>lua vim.lsp.buf.references()<CR>', opts)
88         buf_set_keymap('n', 'K',
89                 '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
90         buf_set_keymap('n', '<leader>rn',
91                 '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
92         buf_set_keymap('n', '[d',
93                 '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
94         buf_set_keymap('n', ']d',
95                 '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
96         buf_set_keymap('n', '<leader>e',
97                 '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
98 end
99
100 -- Add servers
101 local servers = {
102         'clangd'
103 }
104
105 for _, server in ipairs(servers) do
106         lspconfig[server].setup {on_attach = on_attach}
107 end
108
109 vim.opt.signcolumn = 'no'
110
111 -- Jump to files with gf
112 vim.opt.hidden = true
113 vim.opt.path = vim.opt.path + '**'
114
115 -- Disable intro message
116 vim.opt.shortmess = "I"