.config/nvim/init.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
local use = require('packer').use require('packer').startup(function() use 'wbthomason/packer.nvim' -- Package manager use 'neovim/nvim-lspconfig' -- Configurations for Nvim LSP use 'sainnhe/everforest' -- Colorscheme -- Very powerful picker -- use { -- 'nvim-telescope/telescope.nvim', tag = '0.1.1', -- requires = {{ -- 'nvim-lua/plenary.nvim', -- 'BurntSushi/ripgrep', -- 'nvim-treesitter/nvim-treesitter' -- }} -- } end) vim.cmd('colorscheme default') -- solarized, but green -- vim.cmd('set termguicolors') -- needed for truecolor support vim.cmd('set mmp=2000') -- resolves https://github.com/vim/vim/issues/2049 ---- mappings -- local builtin = require('telescope.builtin') local opts = { noremap=true, silent=true } -- telescope -- vim.keymap.set('n', '<space>ff', builtin.find_files, {}) -- vim.keymap.set('n', '<space>fg', builtin.live_grep, {}) -- vim.keymap.set('n', '<space>fb', builtin.buffers, {}) -- vim.keymap.set('n', '<space>fh', builtin.help_tags, {}) -- LSP vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts) vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts) vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts) vim.keymap.set('n', '<space>m', "Go<esc>:put =strftime('%Y-%m-%d')<cr>o============<cr>", opts) -- Use an on_attach function to only map the following keys -- after the language server attaches to the current buffer local on_attach = function(client, bufnr) -- Enable completion triggered by <c-x><c-o> vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') -- Mappings. -- See `:help vim.lsp.*` for documentation on any of the below functions local bufopts = { noremap=true, silent=true, buffer=bufnr } vim.keymap.set('n', 'gd', builtin.lsp_definitions, bufopts) vim.keymap.set('n', 'gi', builtin.lsp_implementations, bufopts) vim.keymap.set('n', 'gr', builtin.lsp_references, bufopts) vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) vim.keymap.set('n', '<C-k>', vim.lsp.buf.hover, bufopts) vim.keymap.set('n', '<space>D', builtin.lsp_type_definitions, bufopts) vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts) end vim.api.nvim_create_autocmd('BufWritePre', { pattern = '*.go', callback = function() vim.lsp.buf.format() vim.lsp.buf.code_action({ context = { only = { 'source.organizeImports' } }, apply = true }) end }) ---- golang require('lspconfig')['gopls'].setup{ on_attach = on_attach, }