Drop neovim

This commit is contained in:
Victor Mignot 2024-07-26 21:32:21 +02:00 committed by Victor Mignot
parent acadf15578
commit 35f28238e6
Signed by: dala
GPG key ID: 5E7F2CE1BEAFED3D
6 changed files with 1 additions and 291 deletions

View file

@ -23,7 +23,6 @@ in
imports = [
./desktop
./development
./neovim
./fish.nix
./termux.nix
./gpg.nix

View file

@ -31,7 +31,7 @@ with lib;
defaultBranch = "main";
};
core = {
editor = "${pkgs.neovim}/bin/nvim";
editor = "${pkgs.helix}/bin/hx";
};
};
};

View file

@ -1,167 +0,0 @@
{
lib,
config,
pkgs,
...
}:
with lib;
{
options.desktop.enableNeovim = mkOption {
type = types.bool;
default = true;
example = false;
description = ''
Whether to use Neovim and its config.
'';
};
config.programs.neovim = mkIf config.desktop.enableNeovim {
enable = true;
viAlias = true;
vimAlias = true;
vimdiffAlias = true;
extraConfig = ''
luafile ${./luaconfig/settings.lua}
luafile ${./luaconfig/keybindings.lua}
luafile ${./luaconfig/lspconfig.lua}
'';
extraPackages = with pkgs; [
nixfmt
nil
ripgrep
entr
];
plugins = with pkgs.vimPlugins; [
# Theming
{
plugin = onenord-nvim;
type = "lua";
config = ''
require('onenord').setup()
'';
}
{
plugin = lualine-nvim;
type = "lua";
config = ''
require('lualine').setup()
'';
}
vim-devicons
# Utility plugins
{
plugin = nerdtree;
type = "lua";
config = ''
vim.g.NERDTreeShowHidden = 1
vim.keymap.set('n', '<C-t>', ':NERDTreeToggle<CR>', { desc = 'Toogle NERDTree pane' })
vim.keymap.set('n', '<C-s>', ':NERDTreeFind<CR>', { desc = 'Search file in NERDTree' })
vim.keymap.set('n', '<C-f>', ':NERDTreeFocus<CR>', { desc = 'Focus on the NERDTreePane' })
-- Keep the same NERDTree pane on each window
vim.api.nvim_create_autocmd("BufWinEnter", { pattern = "*", command = "if getcmdwintype() == \'\' | silent NERDTreeMirror | endif" })
'';
}
nerdtree-git-plugin
{
plugin = toggleterm-nvim;
type = "lua";
config = ''
require("toggleterm").setup{}
vim.keymap.set('n', 'tf', ':ToggleTerm direction=float<CR>', { desc = 'Open a new terminal in float buffer' })
vim.keymap.set('n', 'tt', ':ToggleTerm direction=tab<CR>', { desc = 'Open a new terminal in a new tab' })
vim.keymap.set('n', 'tv', ':ToggleTerm direction=vertical<CR>', { desc = 'Open in a vertical splitted buffer' })
vim.keymap.set('n', 'th', ':ToggleTerm<CR>', { desc = 'Open in a horizontal splitted buffer' })
'';
}
{
plugin = neogit;
type = "lua";
config = ''
require('neogit').setup {}
'';
}
{
plugin = gitsigns-nvim;
type = "lua";
config = ''
require('gitsigns').setup()
'';
}
vim-multiple-cursors
vim-sleuth
vim-commentary
{
plugin = telescope-nvim;
type = "lua";
config = ''
local telescope = require('telescope.builtin')
vim.keymap.set('n', 'ff', telescope.find_files, { desc = 'Search file with Telescope' })
vim.keymap.set('n', 'fg', telescope.live_grep, { desc = 'Live grep with Telescope'})
vim.keymap.set('n', 'fb', telescope.buffers, { desc = 'Search amongst current buffers (opened files)'})
vim.keymap.set('n', 'fh', telescope.help_tags, { desc = 'Search within nvim manual'})
vim.keymap.set('n', 'fs', telescope.lsp_workspace_symbols, { desc = 'Search symbol' })
'';
}
plenary-nvim
telescope-fzy-native-nvim
# Language support plugins
vim-nix
vim-nixhash
{
plugin = rust-vim;
type = "lua";
config = ''
vim.g.rustfmt_autosave = 1
'';
}
vim-markdown
markdown-preview-nvim
{
plugin = vimtex;
type = "viml";
config = ''
let g:vimtex_view_method = 'zathura'
let g:vimtex_compiler_method = 'tectonic'
let g:vimtex_compiler_tectonic = {
\'out_dir' : ' ',
\'hooks' : [],
\'options' : [
\ '--keep-logs',
\ '--synctex',
\ '-Zshell-escape',
\ '-Zshell-escape-cwd=$PWD'
\],
\}
'';
}
# Autocompletion and LSP server
nvim-lspconfig
nvim-cmp
cmp-path
cmp-cmdline
cmp-buffer
cmp-nvim-lsp
vim-vsnip
];
};
config.xdg.configFile.nvim = mkIf config.desktop.enableNeovim {
source = ./luaconfig;
recursive = true;
};
}

View file

@ -1,11 +0,0 @@
-- Navigate around panes
vim.keymap.set('n', '<C-Left>', '<C-w>h', { desc = 'Navigate to left pane' })
vim.keymap.set('n', '<C-Right>', '<C-w>l', { desc = 'Navigate to right pane' })
vim.keymap.set('n', '<C-Up>', '<C-w>k', { desc = 'Navigate to upper pane' })
vim.keymap.set('n', '<C-Down>', '<C-w>j', { desc = 'Toogle lower pane' })
-- Move panes position
vim.keymap.set('n', '<C-S-Left>', '<C-W>H', { desc = 'Navigate to left pane' })
vim.keymap.set('n', '<C-S-Right>', '<C-W>L', { desc = 'Navigate to right pane' })
vim.keymap.set('n', '<C-S-Up>', '<C-W>K', { desc = 'Navigate to upper pane' })
vim.keymap.set('n', '<C-S-Down>', '<C-W>J', { desc = 'Toogle lower pane' })

View file

@ -1,94 +0,0 @@
-- Nvim LSP Config
local map_opts = { noremap=true, silent=true }
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, map_opts)
vim.keymap.set('n', '<space>p', vim.diagnostic.goto_prev, map_opts)
vim.keymap.set('n', '<space>n', vim.diagnostic.goto_next, map_opts)
vim.keymap.set('n', '<space>l', vim.diagnostic.setloclist, map_opts)
-- Enable keybinds on LSP server attach
local on_attach = function(client, bufnr)
-- Enable completion triggered by <C-x><C-o>
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings
local bufopts = { noremap=true, silent=true, buffer=bufnr }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, bufopts)
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
vim.keymap.set('n', '<space>f', function() vim.lsp.buf.format { async = true } end, bufopts)
end
-- Set-up autocompletion
local cmp = require('cmp')
vim.opt.completeopt = {'menu', 'menuone', 'noselect'}
cmp.setup({
snippet = {
-- Necessary snippet engine
expand = function (args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
window = {
-- completion = cmp.config.window.bordered(),
-- documentation = cmp.config.window.bordered,
},
mapping = cmp.mapping.preset.insert({
['<C-u>'] = cmp.mapping.scroll_docs(4),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({select = true}),
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'vsnip' },
}, { { name = 'buffer' } }),
})
-- Language servers setup
local capabilities = require('cmp_nvim_lsp').default_capabilities()
require('lspconfig')['rust_analyzer'].setup {
on_attach = on_attach,
capabilities = capabilities,
}
require('lspconfig')['rnix'].setup {
on_attach = on_attach,
capabilities = capabilities
}
require('lspconfig')["nil_ls"].setup {
on_attach = on_attach,
capabilities = capabilities
}
require('lspconfig')['ltex'].setup {
on_attach = on_attach,
capabilities = capabilities
}
require('lspconfig')['texlab'].setup {
on_attach = on_attach,
capabilities = capabilities
}

View file

@ -1,17 +0,0 @@
-- Set line numbers
vim.opt.number = true
-- Replace tab with whitespaces
vim.opt.expandtab = true
-- Set tabs as 4 whitespaces
vim.opt.tabstop = 4
-- Set indentation adaptability
vim.opt.autoindent = true
-- Set default level of identation
vim.opt.shiftwidth = 4
-- Use the system clipboard
vim.opt.clipboard = 'unnamedplus'