nixos/roles/home/common.nix

210 lines
6.6 KiB
Nix
Raw Normal View History

2021-12-18 21:00:59 +00:00
{ config, pkgs, unstable, ... }:
2021-10-14 12:53:44 +01:00
{
imports = [ ./zsh.nix ./git.nix ];
2021-10-14 12:53:44 +01:00
home = {
2021-11-21 10:36:57 +00:00
stateVersion = "21.05";
2021-10-14 12:53:44 +01:00
sessionVariables = {
EDITOR = "nvim";
VISUAL = "nvim";
};
packages = with pkgs; [ rizin sshfs nixfmt victor-mono ];
2021-10-14 12:53:44 +01:00
};
programs.neovim = {
2021-11-21 10:36:57 +00:00
enable = true;
2021-12-18 21:00:59 +00:00
package = unstable.neovim-unwrapped;
2021-11-25 11:42:32 +00:00
extraPackages = with pkgs; [
nodePackages.prettier
2021-12-08 15:20:36 +00:00
nodePackages.pyright
rnix-lsp
rust-analyzer
2021-11-25 11:42:32 +00:00
cmake-format
clang-tools
rustfmt
];
extraConfig = ''
2021-12-18 21:00:59 +00:00
" syntax
syntax enable
" color themes
set termguicolors
colorscheme molokai
" wildcard mode
set wildmode=longest:full,full
" remapping popup menu (command autocompletion)
" cnoremap <expr> <up> pumvisible() ? "<C-p>" : "<up>
" cnoremap <expr> <down> pumvisible() ? "<C-n>" : "<down>"
" cnoremap <expr> <CR> pumvisible() ? "<C-e>":"<CR>"
" set line numbers
set number
" enable indent guides
let g:indent_guides_enable_on_vim_startup = 1
" Exit Vim if NERDTree is the only window left.
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() |
\ quit | endif
" Start NERDTree. If a file is specified, move the cursor to its window.
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * NERDTree | if argc() > 0 || exists("s:std_in") | wincmd p | endif
" Start NERDTree when Vim starts with a directory argument.
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in') |
\ execute 'NERDTree' argv()[0] | wincmd p | enew | execute 'cd '.argv()[0] | endif
" Exit Vim if NERDTree is the only window left.
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() |
\ quit | endif
" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
" Highlight row and column
set cul
set cuc
" Fix for code not being aligned if between comment blocks
set cindent cinkeys-=0#
set expandtab shiftwidth=2 tabstop=2 softtabstop=2
" Enable alignment
let g:neoformat_basic_format_align = 1
" Enable tab to spaces conversion
let g:neoformat_basic_format_retab = 1
" Enable trimmming of trailing whitespace
let g:neoformat_basic_format_trim = 1
lua << EOF
------------------
-- Setup nvim-cmp.
------------------
-- Set completeopt to have a better completion experience
vim.o.completeopt = 'menuone,noselect'
local cmp = require'cmp'
cmp.setup({
snippet = {
-- REQUIRED - you must specify a snippet engine
expand = function(args)
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
end,
},
mapping = {
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
['<C-e>'] = cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
}),
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'vsnip' }, -- For vsnip users.
}, {
{ name = 'buffer' },
})
})
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline('/', {
sources = {
{ name = 'buffer' }
}
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
-- Setup lspconfig.
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
--------------
-- LSP Servers
--------------
require'lspconfig'.pyright.setup{
capabilities = capabilities
}
require'lspconfig'.rust_analyzer.setup{
capabilities = capabilities
}
require'lspconfig'.rnix.setup{
capabilities = capabilities
}
require'lspconfig'.clangd.setup{
capabilities = capabilities,
cmd = {
"clangd",
"--background-index",
"--clang-tidy",
},
}
-------------------
-- TreeSitter setup
-------------------
require'nvim-treesitter.configs'.setup {
highlight = {
enable = true,
custom_captures = {
-- Highlight the @foo.bar capture group with the "Identifier" highlight group.
["foo.bar"] = "Identifier",
},
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = false,
},
}
2021-12-08 15:20:36 +00:00
EOF
'';
2021-06-27 17:13:17 +01:00
2021-11-21 10:36:57 +00:00
viAlias = true;
vimAlias = true;
2021-12-18 21:00:59 +00:00
plugins = with unstable.vimPlugins; [
2021-07-01 05:23:25 +01:00
vim-nix
molokai
2021-07-01 05:23:25 +01:00
vim-airline
2021-06-27 15:16:08 +01:00
vim-airline-themes
2021-11-21 10:36:57 +00:00
vim-lsp
2021-06-27 15:16:08 +01:00
vim-indent-guides
2021-11-21 10:36:57 +00:00
vim-signify
2021-07-01 05:23:25 +01:00
nerdtree
vim-easy-align
2021-07-07 10:46:26 +01:00
vim-fugitive
2021-10-13 13:29:07 +01:00
vimtex
2021-11-21 10:36:57 +00:00
neoformat
2021-12-08 15:20:36 +00:00
nvim-lspconfig
2021-12-18 21:00:59 +00:00
vim-vsnip
nvim-cmp
cmp-nvim-lsp
2022-03-15 15:58:04 +00:00
(nvim-treesitter.withPlugins (_: unstable.tree-sitter.allGrammars))
2021-12-18 21:00:59 +00:00
nvim-treesitter-textobjects
];
};
}