mirror of
https://github.com/nmasur/dotfiles
synced 2025-04-23 20:22:24 +00:00
Compare commits
3 Commits
96c64c4da1
...
dee7c7302a
Author | SHA1 | Date | |
---|---|---|---|
|
dee7c7302a | ||
|
0d052a6463 | ||
|
8b98b8f29d |
@ -177,6 +177,9 @@
|
|||||||
./modules/neovim/plugins/bufferline.nix
|
./modules/neovim/plugins/bufferline.nix
|
||||||
./modules/neovim/plugins/telescope.nix
|
./modules/neovim/plugins/telescope.nix
|
||||||
./modules/neovim/plugins/lsp.nix
|
./modules/neovim/plugins/lsp.nix
|
||||||
|
./modules/neovim/plugins/completion.nix
|
||||||
|
./modules/neovim/plugins/toggleterm.nix
|
||||||
|
./modules/colorscheme/gruvbox/neovim-gruvbox.nix
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
12
modules/colorscheme/gruvbox/neovim-gruvbox.nix
Normal file
12
modules/colorscheme/gruvbox/neovim-gruvbox.nix
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{ pkgs, ... }: {
|
||||||
|
|
||||||
|
plugins = [ pkgs.vimPlugins.vim-gruvbox8 ];
|
||||||
|
|
||||||
|
vim.g.gruvbox_italicize_strings = 0;
|
||||||
|
vim.o.background = "dark";
|
||||||
|
vimscript = ''
|
||||||
|
let g:gruvbox_italicize_strings = 0
|
||||||
|
colorscheme gruvbox8
|
||||||
|
'';
|
||||||
|
|
||||||
|
}
|
155
modules/neovim/plugins/completion.nix
Normal file
155
modules/neovim/plugins/completion.nix
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
{ pkgs, dsl, ... }: {
|
||||||
|
|
||||||
|
plugins = [
|
||||||
|
pkgs.vimPlugins.cmp-nvim-lsp
|
||||||
|
pkgs.vimPlugins.cmp-buffer
|
||||||
|
pkgs.vimPlugins.cmp-path
|
||||||
|
pkgs.vimPlugins.cmp-cmdline
|
||||||
|
pkgs.vimPlugins.cmp-nvim-lua
|
||||||
|
pkgs.vimPlugins.luasnip
|
||||||
|
pkgs.vimPlugins.cmp_luasnip
|
||||||
|
pkgs.vimPlugins.cmp-rg
|
||||||
|
pkgs.vimPlugins.friendly-snippets
|
||||||
|
];
|
||||||
|
|
||||||
|
use.cmp.setup = dsl.callWith {
|
||||||
|
|
||||||
|
# Disable in telescope buffers
|
||||||
|
enabled = dsl.rawLua ''
|
||||||
|
function()
|
||||||
|
if vim.bo.buftype == "prompt" then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
|
||||||
|
snippet.expand = dsl.rawLua ''
|
||||||
|
function(args)
|
||||||
|
require("luasnip").lsp_expand(args.body)
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
|
||||||
|
mapping = {
|
||||||
|
"['<C-n>']" = dsl.rawLua
|
||||||
|
"require('cmp').mapping.select_next_item({ behavior = require('cmp').SelectBehavior.Insert })";
|
||||||
|
"['<C-p>']" = dsl.rawLua
|
||||||
|
"require('cmp').mapping.select_prev_item({ behavior = require('cmp').SelectBehavior.Insert })";
|
||||||
|
"['<Down>']" = dsl.rawLua
|
||||||
|
"require('cmp').mapping.select_next_item({ behavior = require('cmp').SelectBehavior.Select })";
|
||||||
|
"['<Up>']" = dsl.rawLua
|
||||||
|
"require('cmp').mapping.select_prev_item({ behavior = require('cmp').SelectBehavior.Select })";
|
||||||
|
"['<C-d>']" = dsl.rawLua "require('cmp').mapping.scroll_docs(-4)";
|
||||||
|
"['<C-f>']" = dsl.rawLua "require('cmp').mapping.scroll_docs(4)";
|
||||||
|
"['<C-e>']" = dsl.rawLua "require('cmp').mapping.abort()";
|
||||||
|
"['<CR>']" = dsl.rawLua
|
||||||
|
"require('cmp').mapping.confirm({ behavior = require('cmp').ConfirmBehavior.Replace, select = true, })";
|
||||||
|
"['<C-r>']" = dsl.rawLua
|
||||||
|
"require('cmp').mapping.confirm({ behavior = require('cmp').ConfirmBehavior.Replace, select = true, })";
|
||||||
|
"['<Esc>']" = dsl.rawLua ''
|
||||||
|
function(_)
|
||||||
|
cmp.mapping({
|
||||||
|
i = cmp.mapping.abort(),
|
||||||
|
c = cmp.mapping.close(),
|
||||||
|
})
|
||||||
|
vim.cmd("stopinsert") --- Abort and leave insert mode
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
"['<C-l>']" = dsl.rawLua ''
|
||||||
|
cmp.mapping(function(_)
|
||||||
|
if require("luasnip").expand_or_jumpable() then
|
||||||
|
require("luasnip").expand_or_jump()
|
||||||
|
end
|
||||||
|
end, { "i", "s" })
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
sources = [
|
||||||
|
{ name = "nvim_lua"; }
|
||||||
|
{ name = "nvim_lsp"; }
|
||||||
|
{ name = "luasnip"; }
|
||||||
|
{ name = "path"; }
|
||||||
|
{
|
||||||
|
name = "buffer";
|
||||||
|
keyword_length = 3;
|
||||||
|
max_item_count = 10;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
name = "rg";
|
||||||
|
keyword_length = 6;
|
||||||
|
max_item_count = 10;
|
||||||
|
option = { additional_arguments = "--ignore-case"; };
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
formatting = {
|
||||||
|
fields = [ "kind" "abbr" "menu" ];
|
||||||
|
format = dsl.rawLua ''
|
||||||
|
function(entry, vim_item)
|
||||||
|
local kind_icons = {
|
||||||
|
Text = "",
|
||||||
|
Method = "m",
|
||||||
|
Function = "",
|
||||||
|
Constructor = "",
|
||||||
|
Field = "",
|
||||||
|
Variable = "",
|
||||||
|
Class = "",
|
||||||
|
Interface = "",
|
||||||
|
Module = "",
|
||||||
|
Property = "",
|
||||||
|
Unit = "",
|
||||||
|
Value = "",
|
||||||
|
Enum = "",
|
||||||
|
Keyword = "",
|
||||||
|
Snippet = "",
|
||||||
|
Color = "",
|
||||||
|
File = "",
|
||||||
|
Reference = "",
|
||||||
|
Folder = "",
|
||||||
|
EnumMember = "",
|
||||||
|
Constant = "",
|
||||||
|
Struct = "",
|
||||||
|
Event = "",
|
||||||
|
Operator = "",
|
||||||
|
TypeParameter = "",
|
||||||
|
}
|
||||||
|
vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
|
||||||
|
vim_item.menu = ({
|
||||||
|
luasnip = "[Snippet]",
|
||||||
|
buffer = "[Buffer]",
|
||||||
|
path = "[Path]",
|
||||||
|
rg = "[Grep]",
|
||||||
|
nvim_lsp = "[LSP]",
|
||||||
|
nvim_lua = "[Lua]",
|
||||||
|
})[entry.source.name]
|
||||||
|
return vim_item
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
experimental = {
|
||||||
|
native_menu = false; # Use cmp menu instead of Vim menu
|
||||||
|
ghost_text = true; # Show preview auto-completion
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
lua = ''
|
||||||
|
-- Use buffer source for `/`
|
||||||
|
require('cmp').setup.cmdline("/", {
|
||||||
|
sources = {
|
||||||
|
{ name = "buffer", keyword_length = 5 },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Use cmdline & path source for ':'
|
||||||
|
require('cmp').setup.cmdline(":", {
|
||||||
|
sources = require('cmp').config.sources({
|
||||||
|
{ name = "path" },
|
||||||
|
}, {
|
||||||
|
{ name = "cmdline" },
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
'';
|
||||||
|
|
||||||
|
}
|
40
modules/neovim/plugins/toggleterm.lua
Normal file
40
modules/neovim/plugins/toggleterm.lua
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
vim.keymap.set("t", "<A-CR>", "<C-\\><C-n>") --- Exit terminal mode
|
||||||
|
|
||||||
|
-- Only set these keymaps for toggleterm
|
||||||
|
vim.api.nvim_create_autocmd("TermOpen", {
|
||||||
|
pattern = "term://*toggleterm#*",
|
||||||
|
callback = function()
|
||||||
|
-- vim.keymap.set("t", "<Esc>", "<C-\\><C-n>") --- Exit terminal mode
|
||||||
|
vim.keymap.set("t", "<C-h>", "<C-\\><C-n><C-w>h")
|
||||||
|
vim.keymap.set("t", "<C-j>", "<C-\\><C-n><C-w>j")
|
||||||
|
vim.keymap.set("t", "<C-k>", "<C-\\><C-n><C-w>k")
|
||||||
|
vim.keymap.set("t", "<C-l>", "<C-\\><C-n><C-w>l")
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
local terminal = require("toggleterm.terminal").Terminal
|
||||||
|
|
||||||
|
local basicterminal = terminal:new()
|
||||||
|
function TERM_TOGGLE()
|
||||||
|
basicterminal:toggle()
|
||||||
|
end
|
||||||
|
|
||||||
|
local nixpkgs = terminal:new({ cmd = "nix repl '<nixpkgs>'" })
|
||||||
|
function NIXPKGS_TOGGLE()
|
||||||
|
nixpkgs:toggle()
|
||||||
|
end
|
||||||
|
|
||||||
|
local gitwatch = terminal:new({ cmd = "fish --interactive --init-command 'gh run watch'" })
|
||||||
|
function GITWATCH_TOGGLE()
|
||||||
|
gitwatch:toggle()
|
||||||
|
end
|
||||||
|
|
||||||
|
local k9s = terminal:new({ cmd = "k9s" })
|
||||||
|
function K9S_TOGGLE()
|
||||||
|
k9s:toggle()
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<Leader>t", TERM_TOGGLE)
|
||||||
|
vim.keymap.set("n", "<Leader>P", NIXPKGS_TOGGLE)
|
||||||
|
vim.keymap.set("n", "<Leader>gw", GITWATCH_TOGGLE)
|
||||||
|
vim.keymap.set("n", "<Leader>9", K9S_TOGGLE)
|
13
modules/neovim/plugins/toggleterm.nix
Normal file
13
modules/neovim/plugins/toggleterm.nix
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{ pkgs, dsl, ... }: {
|
||||||
|
|
||||||
|
plugins = [ pkgs.vimPlugins.toggleterm-nvim ];
|
||||||
|
|
||||||
|
use.toggleterm.setup = dsl.callWith {
|
||||||
|
open_mapping = dsl.rawLua "[[<c-\\>]]";
|
||||||
|
hide_numbers = true;
|
||||||
|
direction = "float";
|
||||||
|
};
|
||||||
|
|
||||||
|
lua = builtins.readFile ./toggleterm.lua;
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user