working on converting app.nix
This commit is contained in:
parent
29def924b3
commit
1679f84978
7 changed files with 545 additions and 125 deletions
53
hmModules/apps/neovim.old/plugin/lsp.nix
Normal file
53
hmModules/apps/neovim.old/plugin/lsp.nix
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
{
|
||||
config = lib.mkIf config.neovim.enable {
|
||||
programs.neovim.plugins = let
|
||||
cfgp = config.neovim.plugins;
|
||||
cfgl = config.neovim.languages;
|
||||
|
||||
configText = ''
|
||||
local on_attach = function(_, bufnr)
|
||||
|
||||
local bufmap = function(keys, func)
|
||||
vim.keymap.set('n', keys, func, { buffer = bufnr })
|
||||
end
|
||||
|
||||
bufmap('<leader>r', vim.lsp.buf.rename)
|
||||
bufmap('<leader>a', vim.lsp.buf.code_action)
|
||||
|
||||
bufmap('gd', vim.lsp.buf.definition)
|
||||
bufmap('gD', vim.lsp.buf.declaration)
|
||||
bufmap('gI', vim.lsp.buf.implementation)
|
||||
bufmap('<leader>D', vim.lsp.buf.type_definition)
|
||||
|
||||
'' + lib.strings.optionalString cfgp.telescope.enable ''
|
||||
bufmap('gr', require('telescope.builtin').lsp_references)
|
||||
bufmap('<leader>s', require('telescope.builtin').lsp_document_symbols)
|
||||
bufmap('<leader>S', require('telescope.builtin').lsp_dynamic_workspace_symbols)
|
||||
'' + ''
|
||||
|
||||
bufmap('K', vim.lsp.buf.hover)
|
||||
|
||||
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
|
||||
vim.lsp.buf.format()
|
||||
end, {})
|
||||
end
|
||||
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
'' + lib.strings.optionalString cfgl.c.enable ''
|
||||
require('lspconfig').clangd.setup {}
|
||||
'' + lib.strings.optionalString cfgl.go.enable ''
|
||||
require('lspconfig').gopls.setup {}
|
||||
'' + lib.strings.optionalString cfgl.nix.enable ''
|
||||
require('lspconfig').nil_ls.setup {}
|
||||
'';
|
||||
in with pkgs.vimPlugins; [
|
||||
{
|
||||
plugin = nvim-lspconfig;
|
||||
type = "lua";
|
||||
config = configText;
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
72
hmModules/apps/neovim.old/plugin/nvimcmp.nix
Normal file
72
hmModules/apps/neovim.old/plugin/nvimcmp.nix
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
let
|
||||
cfgp = config.neovim.plugins;
|
||||
in {
|
||||
config = lib.mkIf (config.neovim.enable && cfgp.nvimcmp.enable) {
|
||||
programs.neovim.plugins = let
|
||||
|
||||
configText = ''
|
||||
local cmp = require('cmp')
|
||||
'' + lib.strings.optionalString cfgp.luasnip.enable ''
|
||||
local luasnip = require('luasnip')
|
||||
|
||||
require('luasnip.loaders.from_vscode').lazy_load()
|
||||
luasnip.config.setup {}
|
||||
'' + ''
|
||||
|
||||
cmp.setup {
|
||||
mapping = cmp.mapping.preset.insert {
|
||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete {},
|
||||
['<CR>'] = cmp.mapping.confirm {
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true,
|
||||
},
|
||||
['<Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
'' + lib.strings.optionalString cfgp.luasnip.enable ''
|
||||
elseif luasnip.expand_or_locally_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
'' + ''
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { 'i', 's' }),
|
||||
['<S-Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
'' + lib.strings.optionalString cfgp.luasnip.enable ''
|
||||
elseif luasnip.locally_jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
'' + ''
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { 'i', 's' }),
|
||||
},
|
||||
'' + lib.strings.optionalString cfgp.luasnip.enable ''
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
sources = {
|
||||
{ name = 'luasnip' },
|
||||
},
|
||||
'' + ''
|
||||
}
|
||||
'';
|
||||
in with pkgs.vimPlugins; [
|
||||
{
|
||||
plugin = nvim-cmp;
|
||||
type = "lua";
|
||||
config = configText;
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
43
hmModules/apps/neovim.old/plugin/telescope.nix
Normal file
43
hmModules/apps/neovim.old/plugin/telescope.nix
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
let
|
||||
cfgp = config.neovim.plugins;
|
||||
in {
|
||||
config = lib.mkIf (config.neovim.enable && cfgp.telescope.enable) {
|
||||
programs.neovim.plugins = let
|
||||
configText = ''
|
||||
require('telescope').setup({
|
||||
extensions = {
|
||||
'' + lib.strings.optionalString cfgp.telescope.fzf.enable ''
|
||||
fzf = {
|
||||
fuzzy = true, -- false will only do exact matching
|
||||
override_generic_sorter = true, -- override the generic sorter
|
||||
override_file_sorter = true, -- override the file sorter
|
||||
case_mode = "smart_case", -- or "ignore_case" or "respect_case"
|
||||
-- the default case_mode is "smart_case"
|
||||
}
|
||||
'' + ''
|
||||
}
|
||||
})
|
||||
local builtin = require('telescope.builtin')
|
||||
vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
|
||||
vim.keymap.set('n', '<leader>fg', builtin.git_files, {})
|
||||
|
||||
'' + lib.strings.optionalString cfgp.telescope.fzf.enable ''
|
||||
require('telescope').load_extension('fzf')
|
||||
'';
|
||||
in with pkgs.vimPlugins; [
|
||||
{
|
||||
plugin = telescope-nvim;
|
||||
type = "lua";
|
||||
config = configText;
|
||||
}
|
||||
(lib.mkIf cfgp.nvimcmp.enable telescope-fzf-native-nvim)
|
||||
];
|
||||
|
||||
home.packages = with pkgs; [
|
||||
(lib.mkIf cfgp.telescope.fzf.enable fzf)
|
||||
];
|
||||
|
||||
};
|
||||
}
|
||||
38
hmModules/apps/neovim.old/plugin/treesitter.nix
Normal file
38
hmModules/apps/neovim.old/plugin/treesitter.nix
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
let
|
||||
cfgp = config.neovim.plugins;
|
||||
cfgl = config.neovim.languages;
|
||||
in {
|
||||
config = lib.mkIf (config.neovim.enable && cfgp.treesitter.enable) {
|
||||
programs.neovim.plugins = let
|
||||
configText = ''
|
||||
require('nvim-treesitter.configs').setup {
|
||||
ensure_installed = {},
|
||||
|
||||
auto_install = false,
|
||||
|
||||
highlight = { enable = true },
|
||||
|
||||
indent = { enable = true },
|
||||
}
|
||||
'';
|
||||
|
||||
# I've tried many things, and can't get treesitter plugins changing
|
||||
# dynamically. For not just have them always loaded regardless of config
|
||||
treeplugs = p: [
|
||||
p.tree-sitter-c
|
||||
p.tree-sitter-go
|
||||
p.tree-sitter-nix
|
||||
p.tree-sitter-rust
|
||||
p.tree-sitter-typescript
|
||||
];
|
||||
in with pkgs.vimPlugins; [
|
||||
{
|
||||
plugin = (nvim-treesitter.withPlugins treeplugs);
|
||||
type = "lua";
|
||||
config = configText;
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue