mirror of
https://github.com/itme-brain/nixos.git
synced 2026-03-24 00:29:43 -04:00
reworked nvim
This commit is contained in:
parent
6474455a8e
commit
c6aded3e64
14 changed files with 254 additions and 181 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
{
|
{
|
||||||
programs.home-manager.enable = true;
|
programs.home-manager.enable = true;
|
||||||
imports = [ (import ./modules/default.nix) ];
|
imports = [ (import ./modules) ];
|
||||||
home.stateVersion = "22.11";
|
home.stateVersion = "22.11";
|
||||||
|
|
||||||
home.username = "bryan";
|
home.username = "bryan";
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,16 @@
|
||||||
|
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./alacritty/default.nix
|
./alacritty
|
||||||
./bash/default.nix
|
./bash
|
||||||
./browsers/default.nix
|
./browsers
|
||||||
./corn/default.nix
|
./corn
|
||||||
./fun/default.nix
|
./fun
|
||||||
./git/default.nix
|
./git
|
||||||
./gpg/default.nix
|
./gpg
|
||||||
./gui/default.nix
|
./gui
|
||||||
./neovim/default.nix
|
./neovim
|
||||||
./security/default.nix
|
./security
|
||||||
./utils/default.nix
|
./utils
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ in
|
||||||
position = "top";
|
position = "top";
|
||||||
statusCommand = ''while :; do echo "$(free -h | awk '/^Mem/ {print $3}') '|' $(date +'%I:%M:%S %p') '|' $(date +'%m-%d-%Y')"; sleep 1; done'';
|
statusCommand = ''while :; do echo "$(free -h | awk '/^Mem/ {print $3}') '|' $(date +'%I:%M:%S %p') '|' $(date +'%m-%d-%Y')"; sleep 1; done'';
|
||||||
fonts = {
|
fonts = {
|
||||||
names = [ "Noto Sans" "Noto Emoji" "Noto Color Emoji" ];
|
names = [ "Noto Sans" ];
|
||||||
size = 10.0;
|
size = 10.0;
|
||||||
};
|
};
|
||||||
colors = {
|
colors = {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
''
|
''
|
||||||
|
|
||||||
|
vim.o.relativenumber = true
|
||||||
|
vim.o.number = true
|
||||||
|
vim.cmd('highlight LineNr ctermfg=DarkGray')
|
||||||
|
|
||||||
vim.opt.tabstop = 2
|
vim.opt.tabstop = 2
|
||||||
vim.opt.shiftwidth = 2
|
vim.opt.shiftwidth = 2
|
||||||
vim.opt.expandtab = true
|
vim.opt.expandtab = true
|
||||||
|
|
@ -13,105 +17,6 @@ vim.cmd([[
|
||||||
au BufRead,BufNewFile *.purs set filetype=purescript
|
au BufRead,BufNewFile *.purs set filetype=purescript
|
||||||
]])
|
]])
|
||||||
|
|
||||||
require("config.lazy")
|
|
||||||
|
|
||||||
local lsp = require("lsp-zero").preset({})
|
|
||||||
|
|
||||||
lsp.on_attach(function(client, bufnr)
|
|
||||||
lsp.default_keymaps({ buffer = bufnr })
|
|
||||||
end)
|
|
||||||
|
|
||||||
lsp.setup_servers({
|
|
||||||
"tsserver",
|
|
||||||
"eslint",
|
|
||||||
"hls",
|
|
||||||
"pyright",
|
|
||||||
"nil_ls",
|
|
||||||
"cssls",
|
|
||||||
"html",
|
|
||||||
"jsonls",
|
|
||||||
"diagnosticls",
|
|
||||||
"lua_ls",
|
|
||||||
"marksman",
|
|
||||||
"purescriptls",
|
|
||||||
"tailwindcss",
|
|
||||||
"bashls",
|
|
||||||
})
|
|
||||||
|
|
||||||
require("lspconfig").lua_ls.setup(lsp.nvim_lua_ls())
|
|
||||||
|
|
||||||
lsp.setup()
|
|
||||||
|
|
||||||
local cmp = require("cmp")
|
|
||||||
cmp.setup({
|
|
||||||
snippet = {
|
|
||||||
expand = function(args)
|
|
||||||
require("luasnip").lsp_expand(args.body)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
sources = {
|
|
||||||
{ name = "nvim_lsp" },
|
|
||||||
{ name = "luasnip" },
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
local has_words_before = function()
|
|
||||||
unpack = unpack or table.unpack
|
|
||||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
|
||||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
|
||||||
end
|
|
||||||
|
|
||||||
local luasnip = require("luasnip")
|
|
||||||
|
|
||||||
cmp.setup({
|
|
||||||
enabled = function()
|
|
||||||
-- disable completion in comments
|
|
||||||
local context = require("cmp.config.context")
|
|
||||||
-- keep command mode completion enabled when cursor is in a comment
|
|
||||||
if vim.api.nvim_get_mode().mode == "c" then
|
|
||||||
return true
|
|
||||||
else
|
|
||||||
return not context.in_treesitter_capture("comment") and not context.in_syntax_group("Comment")
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
mapping = {
|
|
||||||
["<Tab>"] = cmp.mapping(function(fallback)
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_next_item()
|
|
||||||
-- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable()
|
|
||||||
-- they way you will only jump inside the snippet region
|
|
||||||
elseif luasnip.expand_or_jumpable() then
|
|
||||||
luasnip.expand_or_jump()
|
|
||||||
elseif has_words_before() then
|
|
||||||
cmp.complete()
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { "i", "s" }),
|
|
||||||
|
|
||||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_prev_item()
|
|
||||||
elseif luasnip.jumpable(-1) then
|
|
||||||
luasnip.jump(-1)
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { "i", "s" }),
|
|
||||||
|
|
||||||
["<CR>"] = cmp.mapping({
|
|
||||||
i = function(fallback)
|
|
||||||
if cmp.visible() and cmp.get_active_entry() then
|
|
||||||
cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false })
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
s = cmp.mapping.confirm({ select = true }),
|
|
||||||
c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }),
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
|
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
|
||||||
-- Disable virtual_text
|
-- Disable virtual_text
|
||||||
|
|
@ -121,4 +26,10 @@ vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagn
|
||||||
require("notify").setup({
|
require("notify").setup({
|
||||||
background_colour = "#000000",
|
background_colour = "#000000",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
vim.api.nvim_set_keymap('n', '<PageUp>', '<PageUp>zz', {noremap = true})
|
||||||
|
vim.api.nvim_set_keymap('n', '<PageDown>', '<PageDown>zz', {noremap = true})
|
||||||
|
vim.api.nvim_set_keymap('n', '<C-U>', '<C-U>zz', {noremap = true})
|
||||||
|
vim.api.nvim_set_keymap('n', '<C-D>', '<C-D>zz', {noremap = true})
|
||||||
''
|
''
|
||||||
|
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
||||||
{ pkgs, ... }:
|
|
||||||
|
|
||||||
#let
|
|
||||||
# github-theme = pkgs.vimUtils.buildVimPlugin {
|
|
||||||
# name = "github-theme";
|
|
||||||
# src = builtins.fetchTarball {
|
|
||||||
# url = "https://github.com/projekt0n/github-nvim-theme/archive/refs/tags/v1.0.0.tar.gz";
|
|
||||||
# sha256 = "15c65qw1sgw3v5wrwbg5f1fqb82qq1yr44g2nrwb7b7m134jyr1h";
|
|
||||||
# };
|
|
||||||
# };
|
|
||||||
#
|
|
||||||
#in
|
|
||||||
with pkgs.vimPlugins;
|
|
||||||
[
|
|
||||||
# {
|
|
||||||
# plugin = github-theme;
|
|
||||||
# config = ''
|
|
||||||
# lua << EOF
|
|
||||||
# vim.cmd('colorscheme github_dark_high_contrast')
|
|
||||||
# EOF
|
|
||||||
# '';
|
|
||||||
# }
|
|
||||||
|
|
||||||
{ plugin = lazygit-nvim; }
|
|
||||||
|
|
||||||
{
|
|
||||||
plugin = LazyVim;
|
|
||||||
config = ''
|
|
||||||
lua << EOF
|
|
||||||
return {
|
|
||||||
{'williamboman/mason.nvim', enabled = false },
|
|
||||||
{'williamboman/mason-lspconfig.nvim', enabled = false },
|
|
||||||
{'nvim-treesitter/nvim-treesitter', enabled = false },
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
plugin = lsp-zero-nvim;
|
|
||||||
config = ''
|
|
||||||
lua << EOF
|
|
||||||
branch = 'v2.x'
|
|
||||||
requires = {
|
|
||||||
{'neovim/nvim-lspconfig'},
|
|
||||||
{'hrsh7th/nvim-cmp'},
|
|
||||||
{'hrsh7th/cmp-nvim-lsp'},
|
|
||||||
{'L3MON4D3/LuaSnip'},
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
plugin = nvim-treesitter.withAllGrammars;
|
|
||||||
config = ''
|
|
||||||
lua << EOF
|
|
||||||
require'nvim-treesitter.configs'.setup {
|
|
||||||
highlight = {
|
|
||||||
enable = true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
]
|
|
||||||
19
homeConfig/modules/neovim/config/plugins/default.nix
Normal file
19
homeConfig/modules/neovim/config/plugins/default.nix
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
{ pkgs, lib, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
theme = import ./theme;
|
||||||
|
treesitter = import ./treesitter;
|
||||||
|
editing = import ./editing;
|
||||||
|
lsp = import ./lsp;
|
||||||
|
luasnip = import ./luasnip;
|
||||||
|
tools = import ./tools;
|
||||||
|
|
||||||
|
in
|
||||||
|
builtins.concatMap (dir: dir { inherit pkgs lib; }) [
|
||||||
|
theme
|
||||||
|
treesitter
|
||||||
|
editing
|
||||||
|
lsp
|
||||||
|
luasnip
|
||||||
|
tools
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
|
||||||
|
with pkgs.vimPlugins;
|
||||||
|
[
|
||||||
|
{ plugin = indent-blankline-nvim; }
|
||||||
|
{ plugin = auto-pairs; }
|
||||||
|
{ plugin = vim-css-color; }
|
||||||
|
]
|
||||||
93
homeConfig/modules/neovim/config/plugins/lsp/default.nix
Normal file
93
homeConfig/modules/neovim/config/plugins/lsp/default.nix
Normal file
|
|
@ -0,0 +1,93 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
|
||||||
|
with pkgs.vimPlugins;
|
||||||
|
[
|
||||||
|
{ plugin = lsp-zero-nvim;
|
||||||
|
config = ''
|
||||||
|
lua << EOF
|
||||||
|
local lsp = require('lsp-zero').preset({})
|
||||||
|
|
||||||
|
lsp.on_attach(function(client, bufnr)
|
||||||
|
lsp.default_keymaps({buffer = bufnr})
|
||||||
|
end)
|
||||||
|
|
||||||
|
lsp.setup_servers({
|
||||||
|
"tsserver",
|
||||||
|
"eslint",
|
||||||
|
"hls",
|
||||||
|
"pyright",
|
||||||
|
"nil_ls",
|
||||||
|
"cssls",
|
||||||
|
"html",
|
||||||
|
"jsonls",
|
||||||
|
"diagnosticls",
|
||||||
|
"lua_ls",
|
||||||
|
"marksman",
|
||||||
|
"purescriptls",
|
||||||
|
"tailwindcss",
|
||||||
|
"bashls",
|
||||||
|
})
|
||||||
|
|
||||||
|
lsp.setup()
|
||||||
|
EOF
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|
||||||
|
{ plugin = null-ls-nvim; }
|
||||||
|
{ plugin = nvim-lspconfig; }
|
||||||
|
{ plugin = cmp-nvim-lsp; }
|
||||||
|
|
||||||
|
{ plugin = nvim-cmp;
|
||||||
|
config = ''
|
||||||
|
lua << EOF
|
||||||
|
local has_words_before = function()
|
||||||
|
unpack = unpack or table.unpack
|
||||||
|
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||||
|
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local luasnip = require("luasnip")
|
||||||
|
local cmp = require'cmp'
|
||||||
|
|
||||||
|
cmp.setup({
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
window = {
|
||||||
|
completion = cmp.config.window.bordered(),
|
||||||
|
documentation = cmp.config.window.bordered(),
|
||||||
|
},
|
||||||
|
|
||||||
|
enabled = function()
|
||||||
|
-- disable completion in comments
|
||||||
|
local context = require("cmp.config.context")
|
||||||
|
-- keep command mode completion enabled when cursor is in a comment
|
||||||
|
if vim.api.nvim_get_mode().mode == "c" then
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return not context.in_treesitter_capture("comment") and not context.in_syntax_group("Comment")
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
|
mapping = cmp.mapping.preset.insert({
|
||||||
|
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||||
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||||
|
['<C-Space>'] = cmp.mapping.complete(),
|
||||||
|
['<C-e>'] = cmp.mapping.abort(),
|
||||||
|
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||||
|
}),
|
||||||
|
|
||||||
|
sources = cmp.config.sources({
|
||||||
|
{ name = 'nvim_lsp' },
|
||||||
|
{ name = 'luasnip' }, -- For luasnip users.
|
||||||
|
}, {
|
||||||
|
{ name = 'buffer' },
|
||||||
|
})
|
||||||
|
})
|
||||||
|
EOF
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
]
|
||||||
26
homeConfig/modules/neovim/config/plugins/luasnip/default.nix
Normal file
26
homeConfig/modules/neovim/config/plugins/luasnip/default.nix
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
|
||||||
|
with pkgs.vimPlugins;
|
||||||
|
[
|
||||||
|
{ plugin = luasnip;
|
||||||
|
config = ''
|
||||||
|
lua << EOF
|
||||||
|
local luasnip = require 'luasnip'
|
||||||
|
|
||||||
|
-- Expand or jump in a snippet
|
||||||
|
vim.api.nvim_set_keymap('i', '<Tab>', '<cmd>lua return luasnip.expand_or_jumpable() and \'<Plug>luasnip-expand-or-jump\' or \'<Tab>\'<CR>', { expr = true, silent = true })
|
||||||
|
|
||||||
|
-- Jump backwards in a snippet
|
||||||
|
vim.api.nvim_set_keymap('i', '<S-Tab>', '<cmd>lua luasnip.jump(-1)<CR>', {silent = true})
|
||||||
|
|
||||||
|
-- Keymaps for Select mode
|
||||||
|
vim.api.nvim_set_keymap('s', '<Tab>', '<cmd>lua require(\'luasnip\').jump(1)<CR>', {silent = true})
|
||||||
|
vim.api.nvim_set_keymap('s', '<S-Tab>', '<cmd>lua require(\'luasnip\').jump(-1)<CR>', {silent = true})
|
||||||
|
|
||||||
|
-- Changing choices in choiceNodes
|
||||||
|
vim.api.nvim_set_keymap('i', '<C-E>', '<cmd>lua return luasnip.choice_active() and \'<Plug>luasnip-next-choice\' or \'<C-E>\'<CR>', { expr = true, silent = true })
|
||||||
|
vim.api.nvim_set_keymap('s', '<C-E>', '<cmd>lua return luasnip.choice_active() and \'<Plug>luasnip-next-choice\' or \'<C-E>\'<CR>', { expr = true, silent = true })
|
||||||
|
EOF
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
]
|
||||||
56
homeConfig/modules/neovim/config/plugins/theme/default.nix
Normal file
56
homeConfig/modules/neovim/config/plugins/theme/default.nix
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
{ pkgs, lib, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
|
||||||
|
panvimdoc = pkgs.fetchFromGitHub {
|
||||||
|
owner = "kdheepak";
|
||||||
|
repo = "panvimdoc";
|
||||||
|
rev = "v3.0.6";
|
||||||
|
sha256 = "0smij72mpd1lm6akjzkmh2z76xfgn86n7n1ah36fz16p1krc1nwv";
|
||||||
|
};
|
||||||
|
github-theme = pkgs.stdenv.mkDerivation {
|
||||||
|
pname = "github-theme";
|
||||||
|
version = "1.0.0";
|
||||||
|
src = pkgs.fetchFromGitHub {
|
||||||
|
owner = "projekt0n";
|
||||||
|
repo = "github-nvim-theme";
|
||||||
|
rev = "v1.0.0";
|
||||||
|
sha256 = "1b9fac3ajqr9i5291k3z3pgrh3l08ga1ghdw05s1nq3xvbzcicn5";
|
||||||
|
};
|
||||||
|
buildInputs = [ pkgs.makeWrapper ];
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
# replace misc/panvimdoc with our pre-fetched version
|
||||||
|
rm -rf misc/panvimdoc
|
||||||
|
ln -s ${panvimdoc} misc/panvimdoc
|
||||||
|
|
||||||
|
# carry on with the build as normal
|
||||||
|
make
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
# install the plugin to $out
|
||||||
|
mkdir -p $out
|
||||||
|
cp -r * $out
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
description = "A dark theme for Neovim";
|
||||||
|
homepage = "https://github.com/projekt0n/github-nvim-theme";
|
||||||
|
license = licenses.mit;
|
||||||
|
platforms = platforms.all;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
in
|
||||||
|
[
|
||||||
|
{
|
||||||
|
plugin = github-theme;
|
||||||
|
config = ''
|
||||||
|
lua << EOF
|
||||||
|
vim.cmd('colorscheme github_dark_high_contrast')
|
||||||
|
EOF
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
|
||||||
|
with pkgs.vimPlugins;
|
||||||
|
[
|
||||||
|
{ plugin = lazygit-nvim; }
|
||||||
|
{ plugin = nvim-web-devicons; }
|
||||||
|
{ plugin = lualine-nvim; }
|
||||||
|
{ plugin = neo-tree-nvim; }
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
{ pkgs, ...}:
|
||||||
|
|
||||||
|
with pkgs.vimPlugins;
|
||||||
|
|
||||||
|
[
|
||||||
|
{ plugin = nvim-treesitter.withAllGrammars;
|
||||||
|
config = ''
|
||||||
|
lua << EOF
|
||||||
|
require'nvim-treesitter.configs'.setup {
|
||||||
|
highlight = {
|
||||||
|
enable = true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
@ -12,9 +12,9 @@ in
|
||||||
viAlias = true;
|
viAlias = true;
|
||||||
vimAlias = true;
|
vimAlias = true;
|
||||||
|
|
||||||
# extraLuaConfig = import ./config/init.nix;
|
extraLuaConfig = import ./config/init.nix;
|
||||||
plugins = import ./config/plugins.nix { inherit pkgs; };
|
plugins = import (./config/plugins) { inherit pkgs lib; };
|
||||||
extraPackages = import ./config/lsp.nix { inherit pkgs; };
|
extraPackages = import ./config/servers.nix { inherit pkgs; };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue