Split dev vim config into own file

This commit is contained in:
Sam W 2022-03-28 23:03:21 +00:00
parent bea19cb5a0
commit 835a3a6018
5 changed files with 81 additions and 59 deletions

49
home/dev.lua Normal file
View File

@ -0,0 +1,49 @@
-- More vim init for "bells and whistles you are using vim for dev" mode
-- LSP
local opts = { noremap=true, silent=true }
local on_attach = function(client, bufnr)
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
end
-- Enable Language LSPs
require'lspconfig'.gopls.setup{
on_attach = on_attach,
}
require'lspconfig'.pylsp.setup{
on_attach = on_attach,
handlers = {
["textDocument/publishDiagnostics"] = vim.lsp.with(
vim.lsp.diagnostic.on_publish_diagnostics, {
-- Disable virtual_text
virtual_text = false
}
),
}
}
require'lspconfig'.rnix.setup{
on_attach = on_attach
}
-- Diags with Trouble
require('trouble').setup {
icons = false,
signs = {
error = "E",
warning = "W",
hint = "H",
information = "I"
}
}
vim.g.rustfmt_autosave = 1
-- Tree-sitter
require'nvim-treesitter.configs'.setup {
highlight = {
enable = true
}
}

View File

@ -17,50 +17,3 @@ vim.o.termguicolors = true
-- Keybinds
vim.api.nvim_set_keymap('n','<C-P>', '<cmd> FZF<CR>', { noremap=true })
-- LSP
local opts = { noremap=true, silent=true }
local on_attach = function(client, bufnr)
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
end
-- Enable Language LSPs
require'lspconfig'.gopls.setup{
on_attach = on_attach,
}
require'lspconfig'.pylsp.setup{
on_attach = on_attach,
handlers = {
["textDocument/publishDiagnostics"] = vim.lsp.with(
vim.lsp.diagnostic.on_publish_diagnostics, {
-- Disable virtual_text
virtual_text = false
}
),
}
}
require'lspconfig'.rnix.setup{
on_attach = on_attach
}
-- Diags with Trouble
require('trouble').setup {
icons = false,
signs = {
error = "E",
warning = "W",
hint = "H",
information = "I"
}
}
vim.g.rustfmt_autosave = 1
-- Tree-sitter
require'nvim-treesitter.configs'.setup {
highlight = {
enable = true
}
}

View File

@ -1,6 +1,17 @@
{
dev = { ... }: { imports = [ ./default.nix ./git.nix ./rust.nix ./vim.nix ]; };
laptop = { ... }: {
imports = [ ./default.nix ./git.nix ./macs.nix ./rust.nix ./vim.nix ./passwords.nix ];
dev = { ... }: {
imports = [ ./default.nix ./git.nix ./rust.nix ./vim.nix ./vim-dev.nix ];
};
laptop = { ... }: {
imports = [
./default.nix
./git.nix
./macs.nix
./rust.nix
./vim.nix
./vim-dev.nix
./passwords.nix
];
};
server = { ... }: { imports = [ ./default.nix ./git.nix ./vim.nix ]; };
}

17
home/vim-dev.nix Normal file
View File

@ -0,0 +1,17 @@
{ pkgs, ... }: {
programs.neovim.plugins = with pkgs.vimPlugins; [
# More fancy shit
nvim-treesitter
# Language stuff
nvim-lspconfig
trouble-nvim
vim-nix
rust-vim
vim-go
];
programs.neovim.extraConfig = ''
lua <<EOF
${builtins.readFile ./dev.lua}
EOF
'';
}

View File

@ -1,6 +1,6 @@
# This module sets up a "full" neovim install with plugins and unicorns. It
# also makes neovim the default editor and aliases vim to nvim.
{ pkgs, ... }: {
{ pkgs, lib, strings, ... }: {
home.sessionVariables = { "EDITOR" = "nvim"; };
home.packages = with pkgs; [ rnix-lsp ripgrep ];
programs.neovim = {
@ -14,14 +14,6 @@
gruvbox-nvim
fzfWrapper # The basic "built in" fzf stuff
fzf-vim # The fancier opt in fzf stuff
# More fancy shit
nvim-treesitter
# Language stuff
nvim-lspconfig
trouble-nvim
vim-nix
rust-vim
vim-go
# Git stuff
fugitive
vim-gitgutter