2023-02-22 21:23:25 +00:00
|
|
|
{ pkgs, ... }:
|
|
|
|
{
|
2022-02-16 15:50:31 +00:00
|
|
|
programs.neovim = {
|
2022-02-06 23:01:27 +00:00
|
|
|
enable = true;
|
2022-03-02 14:27:56 +00:00
|
|
|
withPython3 = true;
|
2022-03-29 14:58:31 +00:00
|
|
|
extraPackages = with pkgs; [
|
2023-02-10 15:36:26 +00:00
|
|
|
nil
|
|
|
|
nixpkgs-fmt
|
2023-08-03 22:04:48 +00:00
|
|
|
gopls
|
|
|
|
pyright
|
2023-09-14 15:13:49 +00:00
|
|
|
vimwiki-markdown
|
2022-03-29 14:58:31 +00:00
|
|
|
(python3.withPackages (ps: with ps; [
|
|
|
|
black
|
|
|
|
flake8
|
2022-05-03 14:12:20 +00:00
|
|
|
pylint
|
|
|
|
jedi
|
2022-03-29 14:58:31 +00:00
|
|
|
]))
|
|
|
|
];
|
2022-02-16 15:50:31 +00:00
|
|
|
vimAlias = true;
|
2022-02-07 17:11:50 +00:00
|
|
|
plugins = with pkgs.vimPlugins; [
|
|
|
|
|
|
|
|
# Nice statusbar at the bottom
|
|
|
|
vim-airline
|
|
|
|
|
|
|
|
# Autoformatter for 'all' languages
|
|
|
|
neoformat
|
|
|
|
|
|
|
|
# Colorscheme
|
2022-11-24 14:32:15 +00:00
|
|
|
papercolor-theme
|
2022-02-16 15:50:31 +00:00
|
|
|
|
2022-07-28 12:27:17 +00:00
|
|
|
# Better support for netrw
|
|
|
|
vim-vinegar
|
2022-02-16 15:50:31 +00:00
|
|
|
|
|
|
|
# Bar at the top for all open buffers
|
|
|
|
bufferline-nvim
|
|
|
|
|
|
|
|
# git diff icons on the left sidebar
|
|
|
|
vim-gitgutter
|
2022-03-02 14:27:56 +00:00
|
|
|
|
|
|
|
# blockcomments
|
|
|
|
tcomment_vim
|
|
|
|
|
2022-04-25 12:26:15 +00:00
|
|
|
# Nix support
|
|
|
|
vim-nix
|
|
|
|
|
2022-04-11 12:28:53 +00:00
|
|
|
# Go plugin from fatih
|
|
|
|
vim-go
|
|
|
|
|
2022-11-24 14:32:15 +00:00
|
|
|
# markdown
|
|
|
|
vim-markdown
|
|
|
|
tabular
|
2023-02-10 15:36:26 +00:00
|
|
|
|
2023-08-03 22:04:48 +00:00
|
|
|
# lsp and completion
|
|
|
|
nvim-lspconfig
|
|
|
|
nvim-cmp
|
|
|
|
cmp-nvim-lsp
|
|
|
|
cmp-buffer
|
|
|
|
|
2023-07-20 13:00:10 +00:00
|
|
|
vim-terraform
|
|
|
|
goyo-vim
|
2023-09-07 16:09:02 +00:00
|
|
|
|
|
|
|
conflict-marker-vim
|
2023-09-14 15:13:49 +00:00
|
|
|
vimwiki
|
|
|
|
|
|
|
|
|
2022-02-07 17:11:50 +00:00
|
|
|
];
|
2022-02-06 23:01:27 +00:00
|
|
|
extraConfig = ''
|
2022-03-29 14:58:31 +00:00
|
|
|
set nocompatible
|
2022-02-06 23:01:27 +00:00
|
|
|
set mouse=a
|
2022-02-16 15:50:31 +00:00
|
|
|
set termguicolors
|
|
|
|
set background=dark
|
2022-11-24 14:32:15 +00:00
|
|
|
set number
|
|
|
|
set laststatus=2
|
|
|
|
colorscheme PaperColor
|
2022-03-02 14:27:56 +00:00
|
|
|
set hlsearch
|
|
|
|
set tabstop=4
|
|
|
|
set shiftwidth=4
|
|
|
|
set softtabstop=4
|
|
|
|
set expandtab
|
|
|
|
set cursorline
|
2022-07-28 12:27:17 +00:00
|
|
|
set scrolloff=5
|
2022-03-02 14:27:56 +00:00
|
|
|
let mapleader = ","
|
2022-07-22 08:50:52 +00:00
|
|
|
set ignorecase
|
|
|
|
set smartcase
|
2022-07-28 12:27:17 +00:00
|
|
|
set colorcolumn=120
|
2022-09-09 14:00:54 +00:00
|
|
|
set textwidth=120
|
2023-09-07 16:09:02 +00:00
|
|
|
set nowrap
|
2022-03-02 14:27:56 +00:00
|
|
|
|
|
|
|
" Autosave when focus is lost
|
|
|
|
:au FocusLost * :wa
|
|
|
|
|
2022-10-25 13:28:35 +00:00
|
|
|
" sync copy/paste buffer from vim with system buffer
|
|
|
|
set clipboard^=unnamed
|
|
|
|
|
2022-03-02 14:27:56 +00:00
|
|
|
""Hotkeys
|
|
|
|
set pastetoggle=<F10>
|
|
|
|
nnoremap <silent><cr> :nohlsearch<CR>
|
|
|
|
inoremap jj <Esc>
|
|
|
|
|
|
|
|
" Faster tab switching
|
|
|
|
map <Tab> :bnext<cr>
|
|
|
|
map <S-Tab> :bprevious<cr>
|
|
|
|
|
|
|
|
" easier moving of code blocks
|
|
|
|
set hidden
|
|
|
|
vnoremap < <gv
|
|
|
|
vnoremap > >gv
|
|
|
|
|
|
|
|
" Permanent undo history
|
|
|
|
set dir=~/.tmp/
|
|
|
|
set backupdir=~/.tmp/bak
|
|
|
|
if v:version >= 703
|
|
|
|
set undodir=~/.tmp/
|
|
|
|
set undofile
|
|
|
|
set undolevels=100
|
|
|
|
set undoreload=1000
|
|
|
|
endif
|
|
|
|
|
2023-02-10 15:36:26 +00:00
|
|
|
" Always show the signcolumn, otherwise it would shift the text each time
|
|
|
|
" diagnostics appear/become resolved
|
|
|
|
set signcolumn=yes
|
|
|
|
|
2023-01-04 11:12:28 +00:00
|
|
|
" dont start with a fully folded document
|
|
|
|
set nofoldenable
|
|
|
|
|
|
|
|
" Remember cursor position
|
|
|
|
autocmd BufReadPost *
|
|
|
|
\ if line("'\"") > 0 && line("'\"") <= line("$") |
|
|
|
|
\ exe "normal! g`\"" |
|
|
|
|
\ endif
|
|
|
|
|
2022-04-11 12:28:53 +00:00
|
|
|
" vim-go
|
|
|
|
au FileType go nmap <leader>r <Plug>(go-run)
|
|
|
|
au FileType go nmap <leader>b <Plug>(go-build)
|
|
|
|
au FileType go nmap <leader>t <Plug>(go-test)
|
|
|
|
let g:go_highlight_functions = 1
|
|
|
|
let g:go_highlight_methods = 1
|
|
|
|
let g:go_highlight_fields = 1
|
|
|
|
let g:go_highlight_types = 1
|
|
|
|
let g:go_highlight_operators = 1
|
|
|
|
let g:go_highlight_build_constraints = 1
|
2023-08-03 22:04:48 +00:00
|
|
|
" Don't use gopls from vim-go
|
|
|
|
let g:go_gopls_enabled = 0
|
2022-04-11 12:28:53 +00:00
|
|
|
|
2023-06-06 13:18:23 +00:00
|
|
|
" neoformat
|
|
|
|
let g:neoformat_python_black = { 'args': ['-l 120'] }
|
|
|
|
|
2023-07-20 13:00:10 +00:00
|
|
|
" Enter goyo mode
|
|
|
|
nmap <Leader>gy :Goyo 50%x100%<CR>
|
2023-08-03 22:04:48 +00:00
|
|
|
|
2023-09-14 15:13:49 +00:00
|
|
|
let g:vimwiki_list = [{
|
|
|
|
\ 'path': '~/workspace/vimwiki',
|
|
|
|
\ 'template_path': '~/workspace/vimwiki/templates/',
|
|
|
|
\ 'template_default': 'default',
|
|
|
|
\ 'syntax': 'markdown',
|
|
|
|
\ 'ext': '.md',
|
|
|
|
\ 'path_html': '~/workspace/vimwiki/site_html/',
|
|
|
|
\ 'custom_wiki2html': 'vimwiki_markdown',
|
|
|
|
\ 'template_ext': '.tpl'}]
|
|
|
|
|
2022-02-16 15:50:31 +00:00
|
|
|
lua << EOF
|
2022-03-02 14:27:56 +00:00
|
|
|
require("bufferline").setup{}
|
2023-08-03 22:04:48 +00:00
|
|
|
|
|
|
|
require('lspconfig').gopls.setup{}
|
|
|
|
require('lspconfig').pyright.setup{}
|
|
|
|
|
|
|
|
vim.api.nvim_create_autocmd('LspAttach', {
|
|
|
|
desc = 'LSP actions',
|
|
|
|
callback = function()
|
|
|
|
local bufmap = function(mode, lhs, rhs)
|
|
|
|
local opts = {buffer = true}
|
|
|
|
vim.keymap.set(mode, lhs, rhs, opts)
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Displays hover information about the symbol under the cursor
|
|
|
|
bufmap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>')
|
|
|
|
|
|
|
|
-- Jump to the definition
|
|
|
|
bufmap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>')
|
|
|
|
|
|
|
|
-- Jump to declaration
|
|
|
|
bufmap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>')
|
|
|
|
|
|
|
|
-- Lists all the implementations for the symbol under the cursor
|
|
|
|
bufmap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>')
|
|
|
|
|
|
|
|
-- Jumps to the definition of the type symbol
|
|
|
|
bufmap('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>')
|
|
|
|
|
|
|
|
-- Lists all the references
|
|
|
|
bufmap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>')
|
|
|
|
|
|
|
|
-- Displays a function's signature information
|
|
|
|
bufmap('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<cr>')
|
|
|
|
|
|
|
|
-- Renames all references to the symbol under the cursor
|
|
|
|
bufmap('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<cr>')
|
|
|
|
|
|
|
|
-- Selects a code action available at the current cursor position
|
|
|
|
bufmap('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>')
|
|
|
|
bufmap('x', '<F4>', '<cmd>lua vim.lsp.buf.range_code_action()<cr>')
|
|
|
|
|
|
|
|
-- Show diagnostics in a floating window
|
|
|
|
bufmap('n', 'gl', '<cmd>lua vim.diagnostic.open_float()<cr>')
|
|
|
|
|
|
|
|
-- Move to the previous diagnostic
|
|
|
|
bufmap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<cr>')
|
|
|
|
|
|
|
|
-- Move to the next diagnostic
|
|
|
|
bufmap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<cr>')
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
vim.opt.completeopt = {'menu', 'menuone', 'noselect'}
|
|
|
|
local cmp = require('cmp')
|
|
|
|
local select_opts = {behavior = cmp.SelectBehavior.Select}
|
|
|
|
cmp.setup({
|
|
|
|
sources = {
|
|
|
|
{name = 'path'},
|
|
|
|
{name = 'nvim_lsp', keyword_length = 1},
|
|
|
|
{name = 'buffer', keyword_length = 3},
|
|
|
|
{name = 'luasnip', keyword_length = 2},
|
|
|
|
},
|
|
|
|
window = {
|
|
|
|
documentation = cmp.config.window.bordered()
|
|
|
|
},
|
|
|
|
formatting = {
|
|
|
|
fields = {'menu', 'abbr', 'kind'}
|
|
|
|
},
|
|
|
|
mapping = {
|
|
|
|
['<CR>'] = cmp.mapping.confirm({select = false}),
|
|
|
|
['<Up>'] = cmp.mapping.select_prev_item(select_opts),
|
|
|
|
['<Down>'] = cmp.mapping.select_next_item(select_opts),
|
|
|
|
|
|
|
|
['<C-p>'] = cmp.mapping.select_prev_item(select_opts),
|
|
|
|
['<C-n>'] = cmp.mapping.select_next_item(select_opts),
|
|
|
|
|
|
|
|
['<C-u>'] = cmp.mapping.scroll_docs(-4),
|
|
|
|
['<C-d>'] = cmp.mapping.scroll_docs(4),
|
|
|
|
|
|
|
|
['<C-e>'] = cmp.mapping.abort(),
|
|
|
|
['<C-y>'] = cmp.mapping.confirm({select = true}),
|
|
|
|
['<CR>'] = cmp.mapping.confirm({select = false}),
|
|
|
|
['<Tab>'] = cmp.mapping(function(fallback)
|
|
|
|
local col = vim.fn.col('.') - 1
|
|
|
|
|
|
|
|
if cmp.visible() then
|
|
|
|
cmp.select_next_item(select_opts)
|
|
|
|
elseif col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then
|
|
|
|
fallback()
|
|
|
|
else
|
|
|
|
cmp.complete()
|
|
|
|
end
|
|
|
|
end, {'i', 's'}),
|
|
|
|
['<S-Tab>'] = cmp.mapping(function(fallback)
|
|
|
|
if cmp.visible() then
|
|
|
|
cmp.select_prev_item(select_opts)
|
|
|
|
else
|
|
|
|
fallback()
|
|
|
|
end
|
|
|
|
end, {'i', 's'}),
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2022-02-16 15:50:31 +00:00
|
|
|
EOF
|
2022-02-06 23:01:27 +00:00
|
|
|
'';
|
|
|
|
};
|
2022-01-26 19:45:40 +00:00
|
|
|
}
|