reworked nvim

This commit is contained in:
Bryan Ramos 2023-06-07 01:22:45 -04:00
parent 6474455a8e
commit c6aded3e64
14 changed files with 254 additions and 181 deletions

View 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
]

View file

@ -0,0 +1,8 @@
{ pkgs, ... }:
with pkgs.vimPlugins;
[
{ plugin = indent-blankline-nvim; }
{ plugin = auto-pairs; }
{ plugin = vim-css-color; }
]

View 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
'';
}
]

View 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
'';
}
]

View 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
'';
}
]

View file

@ -0,0 +1,9 @@
{ pkgs, ... }:
with pkgs.vimPlugins;
[
{ plugin = lazygit-nvim; }
{ plugin = nvim-web-devicons; }
{ plugin = lualine-nvim; }
{ plugin = neo-tree-nvim; }
]

View file

@ -0,0 +1,17 @@
{ pkgs, ...}:
with pkgs.vimPlugins;
[
{ plugin = nvim-treesitter.withAllGrammars;
config = ''
lua << EOF
require'nvim-treesitter.configs'.setup {
highlight = {
enable = true,
},
}
EOF
'';
}
]