feat(wip): port nvim config to nix

main
mandlm 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 htop
ripgrep ripgrep
pavucontrol pavucontrol
gcc gnumake
nodejs
unzip unzip
cargo
rustc
gcc gcc
pkg-config
openssl
];
slack slack
thunderbird thunderbird
signal-desktop signal-desktop
@ -28,16 +22,13 @@
whatsapp-for-linux whatsapp-for-linux
nextcloud-client nextcloud-client
keepassxc keepassxc
direnv
tree
file = { # LSP
".config/nvim/init.lua" = { sumneko-lua-language-server
source = nvim/init.lua; rnix-lsp
}; ];
".config/nvim/lua" = {
source = nvim/lua;
recursive = true;
};
};
stateVersion = "22.05"; stateVersion = "22.05";
}; };
@ -92,6 +83,99 @@
neovim = { neovim = {
enable = true; 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 = { 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) local function nnoremap(key, command)
vim.api.nvim_set_keymap("n", key, command, { noremap = true }) vim.api.nvim_set_keymap("n", key, command, { noremap = true })
end 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 -- termguicolors
vim.opt.termguicolors = true 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) 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 -- language server
use { use {
'junnplus/nvim-lsp-setup', 'junnplus/nvim-lsp-setup',
@ -135,9 +24,6 @@ return require('packer').startup(function(use)
-- null-ls -- null-ls
use { use {
"jose-elias-alvarez/null-ls.nvim", "jose-elias-alvarez/null-ls.nvim",
requres = {
{ "nvim-lua/plenary.nvim" },
},
config = function() config = function()
require("null-ls").setup({ require("null-ls").setup({
sources = { sources = {
@ -150,54 +36,4 @@ return require('packer').startup(function(use)
}) })
end, 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) 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({ sources = require("cmp").config.sources({
{ name = "nvim_lsp" }, { name = "luasnip" }, { name = "path" }, { name = "nvim_lsp" }, { name = "luasnip" }, { name = "path" },
{ name = "buffer" }, { name = "git" }, { name = "buffer" }, { name = "git" }, { name = "nvim-lua" },
{ name = 'nvim_lsp_signature_help' },
{ name = "conventionalcommits" }, { name = "nvim-lua" },
{ name = "calc" } { name = "calc" }
}), }),
mapping = cmp.mapping.preset.insert({ mapping = cmp.mapping.preset.insert({

View File

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

View File

@ -3,7 +3,7 @@ require('nvim-treesitter.configs').setup({
indent = {enable = true}, indent = {enable = true},
ensure_installed = { ensure_installed = {
"bash", "c", "cpp", "css", "dockerfile", "hcl", "html", "javascript", "bash", "c", "cpp", "css", "dockerfile", "hcl", "html", "javascript",
"json", "latex", "lua", "markdown", "python", "rust", "svelte", "toml", "json", "latex", "lua", "markdown", "nix", "python", "rust", "svelte",
"tsx", "typescript", "vim", "vue", "yaml" "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.opt.background = 'dark'
vim.cmd("colorscheme solarized") vim.cmd("colorscheme solarized")