feat(wip): port nvim config to nix

This commit is contained in:
Michael Mandl 2022-06-22 21:50:50 +02:00
parent a9abe9c5bf
commit 8d1dea31b2
Signed by: mandlm
GPG key ID: 4AA25D647AA54CC7
9 changed files with 173 additions and 209 deletions

View file

@ -12,15 +12,9 @@
htop
ripgrep
pavucontrol
gcc
nodejs
gnumake
unzip
cargo
rustc
gcc
pkg-config
openssl
];
slack
thunderbird
signal-desktop
@ -28,16 +22,13 @@
whatsapp-for-linux
nextcloud-client
keepassxc
direnv
tree
file = {
".config/nvim/init.lua" = {
source = nvim/init.lua;
};
".config/nvim/lua" = {
source = nvim/lua;
recursive = true;
};
};
# LSP
sumneko-lua-language-server
rnix-lsp
];
stateVersion = "22.05";
};
@ -92,6 +83,99 @@
neovim = {
enable = true;
plugins = with pkgs.vimPlugins; [
# theme
nvim-solarized-lua
delimitMate
vim-bbye
ansible-vim
# session handling
vim-obsession
vim-prosession
nvim-web-devicons
nvim-treesitter
markdown-preview-nvim # use({ "iamcco/markdown-preview.nvim", run = ":call mkdp#util#install()" })
toggleterm-nvim
nvim-notify
comment-nvim
lualine-nvim
tabline-nvim
indent-blankline-nvim
plenary-nvim
# git
gitsigns-nvim
vim-fugitive
gv-vim
# snippets
friendly-snippets
luasnip
# auto-completion
nvim-cmp
cmp-nvim-lsp
cmp-buffer
cmp-path
cmp-cmdline
cmp-nvim-lua
cmp_luasnip
cmp-calc
# telescope
telescope-nvim
telescope-fzf-native-nvim
telescope-ui-select-nvim
# LSP
nvim-lspconfig
lsp-status-nvim
];
extraConfig = ''
lua << EOF
${builtins.readFile ./nvim/lua/keymaps.lua }
${builtins.readFile ./nvim/lua/options.lua }
${builtins.readFile ./nvim/lua/plugins/treesitter.lua }
${builtins.readFile ./nvim/lua/plugins/lspconfig.lua }
require("toggleterm").setup({ size = 32, open_mapping = [[<F4>]] })
require("notify").setup({ stages = "fade" })
vim.notify = require("notify")
require('Comment').setup({})
require('lualine').setup({
options = { globalstatus = true },
sections = {
lualine_c = { { "filename", path = 1 }, "require('lsp-status').status()" }
},
extensions = { "toggleterm" }
})
require('tabline').setup({ enable = true, options = { show_bufnr = true, show_filename_only = true }})
require("indent_blankline").setup {
char = "",
buftype_exclude = { "terminal", "help", "nofile" },
filetype_exclude = { 'help', 'packer' },
show_trailing_blankline_indent = false
}
require('gitsigns').setup()
require("luasnip.loaders.from_vscode").lazy_load()
${builtins.readFile ./nvim/lua/plugins/nvim-cmp.lua }
${builtins.readFile ./nvim/lua/plugins/telescope.lua }
${builtins.readFile ./nvim/lua/themes.lua }
EOF
'';
};
tmux = {

View file

@ -1,11 +1,3 @@
-- source file everytime it changes
vim.cmd([[
augroup user_keymaps
autocmd!
autocmd BufWritePost keymaps.lua source <afile>
augroup end
]])
local function nnoremap(key, command)
vim.api.nvim_set_keymap("n", key, command, { noremap = true })
end

View file

@ -1,11 +1,3 @@
-- source file everytime it changes
vim.cmd([[
augroup user_options
autocmd!
autocmd BufWritePost options.lua source <afile>
augroup end
]])
-- termguicolors
vim.opt.termguicolors = true

View file

@ -1,115 +1,4 @@
local fn = vim.fn
-- boostrap packer
local install_path = fn.stdpath('data') .. '/site/pack/packer/opt/packer.nvim'
local packer_bootstrap
if fn.empty(fn.glob(install_path)) > 0 then
packer_bootstrap = fn.system({
'git', 'clone', 'https://github.com/wbthomason/packer.nvim',
install_path
})
end
-- run PackerSync everytime plugins.lua is updated
vim.cmd([[
augroup packer_user_config
autocmd!
autocmd BufWritePost plugins.lua source <afile> | PackerSync
augroup end
]])
vim.cmd([[packadd packer.nvim]])
-- initialize plugins
return require('packer').startup(function(use)
-- let packer manage itself
use({ 'wbthomason/packer.nvim', opt = true })
-- theme
use("ishan9299/nvim-solarized-lua")
-- commenting
use {
'numToStr/Comment.nvim',
config = function() require('Comment').setup({}) end
}
-- session handling
use('tpope/vim-obsession')
use('dhruvasagar/vim-prosession')
-- tabline
use {
'kdheepak/tabline.nvim',
config = function()
require 'tabline'.setup {
enable = true,
options = { show_bufnr = true, show_filename_only = true }
}
end,
requires = {
{ 'hoob3rt/lualine.nvim' },
{ 'kyazdani42/nvim-web-devicons', opt = true }
}
}
-- status line
use {
'nvim-lualine/lualine.nvim',
requires = { 'kyazdani42/nvim-web-devicons', opt = true },
config = function()
require('lualine').setup({
options = { globalstatus = true },
sections = {
lualine_c = { { "filename", path = 1 }, "require('lsp-status').status()" }
},
extensions = { "toggleterm" }
})
end
}
-- blankline
use({
"lukas-reineke/indent-blankline.nvim",
config = function()
require("indent_blankline").setup {
char = "",
buftype_exclude = { "terminal", "help", "nofile" },
filetype_exclude = { 'help', 'packer' },
show_trailing_blankline_indent = false
}
end
})
-- git
use('tpope/vim-fugitive')
use({
'lewis6991/gitsigns.nvim',
requires = { 'nvim-lua/plenary.nvim' },
config = function() require('gitsigns').setup() end
})
use("junegunn/gv.vim")
-- autocompletion
use({
"L3MON4D3/LuaSnip",
requires = { "rafamadriz/friendly-snippets" },
config = function()
require("luasnip.loaders.from_vscode").lazy_load()
end
})
use({
"hrsh7th/nvim-cmp",
requires = {
"hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-buffer", "hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline", "hrsh7th/cmp-git", "hrsh7th/cmp-nvim-lua",
"saadparwaiz1/cmp_luasnip", "hrsh7th/cmp-nvim-lsp-signature-help",
"davidsierradz/cmp-conventionalcommits", "hrsh7th/cmp-nvim-lua",
"hrsh7th/cmp-calc"
},
config = function() require('plugins.nvim-cmp') end,
})
-- language server
use {
'junnplus/nvim-lsp-setup',
@ -135,9 +24,6 @@ return require('packer').startup(function(use)
-- null-ls
use {
"jose-elias-alvarez/null-ls.nvim",
requres = {
{ "nvim-lua/plenary.nvim" },
},
config = function()
require("null-ls").setup({
sources = {
@ -150,54 +36,4 @@ return require('packer').startup(function(use)
})
end,
}
-- treesitter
use({
'nvim-treesitter/nvim-treesitter',
config = function() require('plugins.treesitter') end,
run = ':TSUpdate'
})
-- Telescope
use({
"nvim-telescope/telescope.nvim",
requires = {
{ "nvim-lua/plenary.nvim" },
{ "nvim-telescope/telescope-fzf-native.nvim", run = "make" },
{ "nvim-telescope/telescope-ui-select.nvim" },
},
config = function() require("plugins.telescope") end
})
-- automatic pairs
use({ "Raimondi/delimitMate" })
-- markdown preview
use({ "iamcco/markdown-preview.nvim", run = ":call mkdp#util#install()" })
-- terminal
use({
"akinsho/nvim-toggleterm.lua",
config = function()
require("toggleterm").setup({ size = 32, open_mapping = [[<F4>]] })
end
})
-- buffer closing
use({ "sar/bbye.nvim" })
-- ansible filetype
use({ "pearofducks/ansible-vim" })
-- nvim-notify
use({ "rcarriga/nvim-notify",
config = function()
require("notify").setup({
stages = "fade",
})
vim.notify = require("notify")
end
})
if packer_bootstrap then require('packer').sync() end
end)

View file

@ -0,0 +1,69 @@
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
local on_attach = function(client, bufnr)
local function nnoremap(key, command)
vim.keymap.set("n", key, command, { noremap = true, silent = true, buffer = bufnr })
end
local telescope = require("telescope.builtin")
nnoremap("gD", vim.lsp.buf.declaration)
nnoremap("gd", telescope.lsp_definitions)
nnoremap("gt", telescope.lsp_type_definitions)
nnoremap("gi", telescope.lsp_implementations)
nnoremap("gr", telescope.lsp_references)
nnoremap("K", vim.lsp.buf.hover)
nnoremap("<C-k>", vim.lsp.buf.signature_help)
nnoremap("<leader>rn", vim.lsp.buf.rename)
nnoremap("<leader>ca", vim.lsp.buf.code_action)
nnoremap("<leader>f", vim.lsp.buf.formatting)
nnoremap("<leader>d", telescope.diagnostics)
nnoremap("<C-p>", vim.diagnostic.goto_prev)
nnoremap("<C-n>", vim.diagnostic.goto_next)
if client.supports_method("textDocument/formatting") then
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup,
buffer = bufnr,
callback = function()
vim.lsp.buf.formatting_sync()
end,
})
end
end
local lsp_status = require("lsp-status")
lsp_status.config({
current_function = false,
show_filename = false,
diagnostics = true,
})
lsp_status.register_progress()
local capabilities = vim.tbl_extend("keep", vim.lsp.protocol.make_client_capabilities(), lsp_status.capabilities)
capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities)
local servers = {
["sumneko_lua"] = {
Lua = {
diagnostics = {
globals = { "vim" },
},
telemetry = {
enable = false,
},
},
},
["rnix"] = {},
}
local lspconfig = require("lspconfig")
for lsp, config in pairs(servers) do
lspconfig[lsp].setup({
settings = config or {},
on_attach = on_attach,
capabilities = capabilities,
})
end

View file

@ -16,9 +16,7 @@ cmp.setup({
},
sources = require("cmp").config.sources({
{ name = "nvim_lsp" }, { name = "luasnip" }, { name = "path" },
{ name = "buffer" }, { name = "git" },
{ name = 'nvim_lsp_signature_help' },
{ name = "conventionalcommits" }, { name = "nvim-lua" },
{ name = "buffer" }, { name = "git" }, { name = "nvim-lua" },
{ name = "calc" }
}),
mapping = cmp.mapping.preset.insert({

View file

@ -39,6 +39,7 @@ require("nvim-lsp-setup").setup({
eslint = {},
jsonls = {},
pylsp = {},
rnix = {},
rust_analyzer = require("nvim-lsp-setup.rust-tools").setup({
server = {
settings = {

View file

@ -3,7 +3,7 @@ require('nvim-treesitter.configs').setup({
indent = {enable = true},
ensure_installed = {
"bash", "c", "cpp", "css", "dockerfile", "hcl", "html", "javascript",
"json", "latex", "lua", "markdown", "python", "rust", "svelte", "toml",
"tsx", "typescript", "vim", "vue", "yaml"
"json", "latex", "lua", "markdown", "nix", "python", "rust", "svelte",
"toml", "tsx", "typescript", "vim", "vue", "yaml"
}
})

View file

@ -1,10 +1,2 @@
-- source file everytime it changes
vim.cmd([[
augroup user_theme_config
autocmd!
autocmd BufWritePost themes.lua source <afile>
augroup end
]])
vim.opt.background = 'dark'
vim.cmd("colorscheme solarized")