Created
June 23, 2021 18:28
-
-
Save dancompton/389e0d90d0cf4717ed81fd4631f83d60 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local fn = vim.fn | |
local install_path = '~/.local/share/nvim/site/pack/packer/start/packer.nvim' | |
vim.cmd [[packadd packer.nvim]] | |
local function load_plugins() | |
local use = require('packer').use | |
require("packer").startup( | |
{ | |
function() | |
use 'wbthomason/packer.nvim' | |
use { | |
'lewis6991/gitsigns.nvim', | |
requires = { | |
'nvim-lua/plenary.nvim' | |
}, | |
config = function() | |
require('gitsigns').setup() | |
end | |
} | |
use { | |
'nvim-telescope/telescope.nvim', | |
requires = {{'nvim-lua/popup.nvim'}, {'nvim-lua/plenary.nvim'}} | |
} | |
use 'chriskempson/base16-vim' | |
use 'neovim/nvim-lspconfig' | |
end | |
} | |
) | |
end | |
_G.load_config = function() | |
vim.lsp.set_log_level("trace") | |
local nvim_lsp = require('lspconfig') | |
local on_attach = function(_, bufnr) | |
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end | |
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end | |
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') | |
-- Mappings. | |
local opts = { noremap=true, silent=true } | |
buf_set_keymap('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts) | |
buf_set_keymap('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts) | |
buf_set_keymap('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts) | |
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts) | |
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts) | |
buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts) | |
buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts) | |
buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts) | |
buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts) | |
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts) | |
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts) | |
buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts) | |
buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts) | |
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts) | |
buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts) | |
end | |
-- Add the server that troubles you here | |
nvim_lsp['gopls'].setup { | |
cmd = {'gopls'}, | |
on_attach = on_attach | |
} | |
end | |
if fn.isdirectory(install_path) == 0 then | |
fn.system({'git', 'clone', 'https://github.com/wbthomason/packer.nvim', install_path}) | |
load_plugins() | |
require('packer').sync() | |
vim.cmd 'autocmd User PackerComplete ++once lua load_config()' | |
else | |
load_plugins() | |
_G.load_config() | |
end | |
local scopes = {o = vim.o, b = vim.bo, w = vim.wo} | |
local opt = function(scope, key, value) | |
scopes[scope][key] = value | |
if scope ~= 'o' then scopes['o'][key] = value end | |
end | |
opt('b', 'expandtab', true) | |
opt('b', 'shiftwidth', 2) | |
opt('b', 'smartindent', true) -- Insert indents automatically | |
opt('b', 'tabstop', 2) -- Number of spaces tabs count for | |
opt('o', 'completeopt', 'menuone,noinsert,noselect') -- Completion options (for deoplete) | |
opt('o', 'hidden', true) -- Enable modified buffers in background | |
opt('o', 'ignorecase', true) -- Ignore case | |
opt('o', 'joinspaces', false) -- No double spaces with join after a dot | |
opt('o', 'scrolloff', 4 ) -- Lines of context | |
opt('o', 'shiftround', true) -- Round indent | |
opt('o', 'sidescrolloff', 8 ) -- Columns of context | |
opt('o', 'smartcase', true) -- Don't ignore case with capitals | |
opt('o', 'splitbelow', true) -- Put new windows below current | |
opt('o', 'splitright', true) -- Put new windows right of current | |
opt('o', 'termguicolors', true) -- True color support | |
opt('o', 'wildmode', 'list:longest') -- Command-line completion mode | |
opt('w', 'list', true) -- Show some invisible characters (tabs...) | |
opt('w', 'number', true) -- Print line number | |
opt('w', 'relativenumber', true) -- Relative line numbers | |
opt('w', 'wrap', false) -- Disable line wrap | |
vim.cmd 'colorscheme base16-tomorrow-night' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment