nixbook: nixvim

nixbook: add more nixvim plugins
This commit is contained in:
Tristan 2024-07-30 13:29:13 +01:00 committed by Tristan Beedell
parent ce02fb7bee
commit 88ce520e29
9 changed files with 470 additions and 193 deletions

View file

@ -14,7 +14,6 @@
text = config.lib.stylix.colors.base05;
};
rgb = color: "rgb(${color})";
in {
imports = [
(import ../utils/waybar.nix)

View file

@ -1,30 +0,0 @@
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
vim.o.relativenumber = true
vim.o.number = true
vim.o.signcolumn = 'yes'
vim.o.tabstop = 2
vim.o.shiftwidth = 2
vim.o.expandtab = true
vim.o.smartindent = true
vim.o.scrolloff = 4
vim.o.undofile = true
vim.o.undodir = vim.fn.expand("$HOME/.local/share/nvim/undo")
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
vim.keymap.set("x", "p", "\"_dP")
vim.keymap.set("n", "<leader>y", "\"+y")
vim.keymap.set("v", "<leader>y", "\"+y")
-- Global mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float)
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist)
vim.keymap.set('v', '<C-c>', '"+y')
vim.keymap.set('i', '<C-v>', '<escape>"+p')

View file

@ -1,56 +1,9 @@
{pkgs, ...}: {
programs.neovim = {
enable = true;
defaultEditor = true;
extraLuaConfig = ''
${builtins.readFile ./config.lua}
'';
extraPackages = with pkgs; [
nodePackages_latest.typescript-language-server
vscode-langservers-extracted
gopls
nil
rust-analyzer
];
plugins = with pkgs.vimPlugins; [
{
plugin = nvim-surround;
type = "lua";
config = ''
require("nvim-surround").setup()
'';
}
{
plugin = comment-nvim;
type = "lua";
config = ''
require("Comment").setup()
'';
}
{
plugin = vimwiki;
config = ''
let g:vimwiki_list = [{'path': '~/Documents/vimwiki/', 'syntax': 'markdown', 'ext': '.md'}]
'';
}
{
plugin = telescope-nvim;
type = "lua";
config = ''
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
vim.keymap.set('n', '<leader>fb', builtin.buffers, {})
vim.keymap.set('n', '<leader>fh', builtin.help_tags, {})
'';
}
{
plugin = nvim-lspconfig;
type = "lua";
config = builtins.readFile ./lspconfig.lua;
}
];
};
programs.nixvim =
{
enable = true;
}
// import ../../../lib/nixvim.nix;
programs.vscode = {
extensions = [pkgs.vscode-extensions.asvetliakov.vscode-neovim];

View file

@ -1,54 +0,0 @@
-- Setup language servers.
local lspconfig = require('lspconfig')
local on_attach = function(client)
require'completion'.on_attach(client)
client.server_capabilities.documentFormattingProvider = false
end
lspconfig.tsserver.setup {
on_attach = on_attach
}
lspconfig.eslint.setup {
on_attach = on_attach
}
lspconfig.rust_analyzer.setup {
on_attach = on_attach
}
lspconfig.gopls.setup {}
lspconfig.nil_ls.setup {}
lspconfig.rust_analyzer.setup {}
-- Use LspAttach autocommand to only map the following keys
-- after the language server attaches to the current buffer
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
callback = function(ev)
-- Enable completion triggered by <c-x><c-o>
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
-- Buffer local mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local opts = { buffer = ev.buf }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
vim.keymap.set('n', '<leader>wa', vim.lsp.buf.add_workspace_folder, opts)
vim.keymap.set('n', '<leader>wr', vim.lsp.buf.remove_workspace_folder, opts)
vim.keymap.set('n', '<leader>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, opts)
vim.keymap.set('n', '<leader>D', vim.lsp.buf.type_definition, opts)
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
vim.keymap.set('n', '<leader>f', function()
vim.lsp.buf.format { async = true }
end, opts)
end,
})