This commit is contained in:
iofq 2023-05-12 04:34:16 -05:00
parent 4c341f6650
commit f6a92831f4
10 changed files with 290 additions and 43 deletions

7
config/init.lua Executable file
View file

@ -0,0 +1,7 @@
require("blankline-conf")
require("leap-conf")
require("nvim-conf")
require("nvim-treesitter-conf")
require("plugins-conf")
require("telescope-conf")
require("toggleterm-conf")

6
config/lua/blankline-conf.lua Executable file
View file

@ -0,0 +1,6 @@
vim.cmd([[ hi IndentBlanklineChar ctermfg=240 ]])
vim.cmd([[ hi IndentBlanklineContextChar ctermfg=7 ]])
require("indent_blankline").setup {
show_current_context = true,
show_current_context_start = true,
}

5
config/lua/leap-conf.lua Executable file
View file

@ -0,0 +1,5 @@
local leap = require('leap')
leap.set_default_keymaps()
leap.init_highlight(true)
vim.cmd([[ hi LeapLabelPrimary ctermbg=251 ctermfg=0 ]])

90
config/lua/nvim-conf.lua Executable file
View file

@ -0,0 +1,90 @@
-- vim settings
----------------------------------------
vim.opt.autoindent = true
vim.opt.background = "light"
vim.opt.backspace = "indent,eol,start"
vim.opt.backup = false -- and auto backps, to instead use
vim.opt.breakindent = true
vim.opt.clipboard = "unnamedplus" -- use system clipboard
vim.opt.completeopt = "menuone"
vim.opt.cursorline = true
vim.opt.expandtab = true -- insert tabs as spaces
vim.opt.guicursor = "" -- fixes alacritty changing cursor
vim.opt.hidden = true -- dont save when switching buffers
vim.opt.hlsearch = true
vim.opt.ignorecase = true -- ignore case in searches
vim.opt.inccommand = "split" -- incremental live completion
vim.opt.incsearch = true
vim.opt.laststatus = 1
vim.opt.list = true
vim.opt.listchars:append("trail:·")
vim.opt.mouse = "a"
vim.opt.nrformats:append("alpha") -- let Ctrl-a do letters as well
vim.opt.number = true
vim.opt.pastetoggle = "<F2>"
vim.opt.path:append("**") -- enable fuzzy :find ing
vim.opt.relativenumber = true
vim.opt.shadafile = "NONE" -- disable shada
vim.opt.shiftwidth = 0 -- >> shifts by tabstop
vim.opt.showmatch = true -- highlight matching brackets
vim.opt.signcolumn= "number"
vim.opt.smartcase = true -- unless capital query
vim.opt.smartindent = true -- indent according to lang
vim.opt.softtabstop = -1 -- backspace removes tabstop
vim.opt.splitbelow = true
vim.opt.splitright = true
vim.opt.swapfile = false -- disable swapfiles
vim.opt.tabstop = 4 -- 4 space tabs
vim.opt.undofile = true -- enable auto save of undos
vim.opt.updatetime = 250 -- decrease update time
vim.opt.virtualedit = "onemore"
vim.opt.wildmenu = true
vim.g.netrw_banner = 0 -- disable annoying banner
vim.g.netrw_altv = 1 -- open splits to the right
vim.g.netrw_liststyle = 3 -- tree view
vim.g.fzf_layout = { window = { width = 0.9, height = 0.6 } }
vim.g.indent_blankline_use_treesitter = true
-- mappings
----------------------------------------
-- local func to set keybinds
local remap = function(type, key, value)
vim.api.nvim_set_keymap(type,key,value,{noremap = true, silent = true});
end
remap("i", "wq", "<esc>l")
remap("v", "wq", "<esc>l")
remap("n","gr", "gT")
remap("i", "{<CR>", "{<CR>}<Esc>O")
remap("i", "(<CR>", "(<CR>)<Esc>O")
remap("n", "<C-L>", "<Cmd>nohlsearch<Bar>diffupdate<CR><C-L>")
remap("n","n", "nzz")
remap("n", "N", "Nzz")
remap("n", "Y", "y$")
remap("n","[<space>", ":<c-u>put!=repeat([''],v:count)<bar>']+1<cr>")
remap("n","]<space>", ":<c-u>put =repeat([''],v:count)<bar>'[-1<cr><Esc>")
-- autocmd
----------------------------------------
local undopath = "~/.local/share/nvim/undo"
vim.api.nvim_create_autocmd("VimEnter", {
command = "silent !mkdir -p " .. undopath,
group = vim.api.nvim_create_augroup("Init", {}),
})
local toggle_rel_num = vim.api.nvim_create_augroup("ToggleRelNum", {})
vim.api.nvim_create_autocmd("InsertEnter", {
command = "set norelativenumber",
group = toggle_rel_num,
})
vim.api.nvim_create_autocmd("InsertLeave", {
command = "set relativenumber",
group = toggle_rel_num,
})
vim.api.nvim_create_autocmd("TextYankPost", {
callback = function()
vim.highlight.on_yank({ higroup = "Visual" })
end,
group = vim.api.nvim_create_augroup("YankHighlight", {}),
})

View file

@ -0,0 +1,51 @@
require("nvim-treesitter.configs").setup {
ensure_installed = {},
highlight = {
enable = true,
},
indent = {
enable = true,
},
textobjects = {
select = {
enable = true,
lookahead = true,
keymaps = {
['ac'] = '@comment.outer',
['ic'] = '@comment.inner',
["af"] = "@function.outer",
["if"] = "@function.inner",
["aa"] = "@call.inner",
},
},
move = {
enable = true,
set_jumps = true, -- whether to set jumps in the jumplist
goto_next_start = {
[']]'] = '@function.outer',
[']m'] = '@class.outer',
},
goto_next_end = {
[']['] = '@function.outer',
[']M'] = '@class.outer',
},
goto_previous_start = {
['[['] = '@function.outer',
['[m'] = '@class.outer',
},
goto_previous_end = {
['[]'] = '@function.outer',
['[M'] = '@class.outer',
},
},
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = '<CR>',
scope_incremental = '<CR>',
node_incremental = '<TAB>',
node_decremental = '<S-TAB>',
},
},
}

2
config/lua/plugins-conf.lua Executable file
View file

@ -0,0 +1,2 @@
-- telescope
----------------------------------------

44
config/lua/telescope-conf.lua Executable file
View file

@ -0,0 +1,44 @@
local telescope = require("telescope.builtin")
vim.keymap.set("n", "<leader>fb", telescope.buffers, {noremap = true, silent = true})
vim.keymap.set("n", "<leader>ff", telescope.find_files, {noremap = true, silent = true})
vim.keymap.set("n", "<leader>fg", telescope.git_files, {noremap = true, silent = true})
vim.keymap.set("n", "<leader>fv", telescope.command_history, {noremap = true, silent = true})
vim.keymap.set("n", "<leader><leader>", telescope.live_grep, {noremap = true, silent = true})
vim.keymap.set("n", "<leader>8", telescope.grep_string, {noremap = true, silent = true})
vim.keymap.set("n", "<leader>fd", telescope.lsp_definitions, {noremap = true, silent = true})
-- fix highlighting
vim.cmd([[ hi telescopeselection ctermfg=242 ctermbg=252 ]])
require("telescope").setup({
defaults = {
layout_strategy = "vertical",
layout_config = { width = .90, },
vimgrep_arguments = {
"rg",
"--color=never",
"--no-heading",
"--hidden",
"--with-filename",
"--line-number",
"--column",
"--smart-case"
},
mappings = {
i = {
["<esc>"] = require("telescope.actions").close,
["<C-k>"] = require("telescope.actions").move_selection_previous,
["<C-j>"] = require("telescope.actions").move_selection_next,
},
},
},
pickers = {
find_files = {
hidden = true,
find_command = { 'rg', '--files', '--iglob', '!.git', '--hidden' }
},
git_files = {
hidden = true,
find_command = { 'rg', '--files', '--iglob', '!.git', '--hidden' }
},
}
})

5
config/lua/toggleterm-conf.lua Executable file
View file

@ -0,0 +1,5 @@
require("toggleterm").setup{
open_mapping = [[<leader>t]],
shade_terminals = true,
size = vim.o.lines * 0.4
}

122
flake.nix
View file

@ -10,49 +10,87 @@
flake-utils, flake-utils,
... ...
}: }:
flake-utils.lib.eachDefaultSystem (system: let flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
}; };
recursiveMerge = attrList: let recursiveMerge = attrList: let
f = attrPath: f = attrPath:
builtins.zipAttrsWith (n: values: builtins.zipAttrsWith (n: values:
if pkgs.lib.tail values == [] if pkgs.lib.tail values == []
then pkgs.lib.head values then pkgs.lib.head values
else if pkgs.lib.all pkgs.lib.isList values else if pkgs.lib.all pkgs.lib.isList values
then pkgs.lib.unique (pkgs.lib.concatLists values) then pkgs.lib.unique (pkgs.lib.concatLists values)
else if pkgs.lib.all pkgs.lib.isAttrs values else if pkgs.lib.all pkgs.lib.isAttrs values
then f (attrPath ++ [n]) values then f (attrPath ++ [n]) values
else pkgs.lib.last values); else pkgs.lib.last values);
in in
f [] attrList; f [] attrList;
in rec { in rec {
deps = with pkgs; [ deps = with pkgs; [
fzf bash
]; fzf
neovim-with-deps = recursiveMerge [ ripgrep
pkgs.neovim-unwrapped gopls
{buildInputs = deps;} ];
]; neovim-with-deps = recursiveMerge [
packages.iofqvim = pkgs.wrapNeovim neovim-with-deps { pkgs.neovim-unwrapped
viAlias = true; {buildInputs = deps;}
vimAlias = true; ];
extraMakeWrapperArgs = ''--prefix PATH : "${pkgs.lib.makeBinPath deps}"''; packages.iofqvim = pkgs.wrapNeovim neovim-with-deps {
configure = { viAlias = true;
plugins = with pkgs.vimPlugins; { vimAlias = true;
plugs = with pkgs.vimPlugins; [ extraMakeWrapperArgs = ''--prefix PATH : "${pkgs.lib.makeBinPath deps}"'';
configure = {
customRC =
''
lua << EOF
package.path = "${self}/config/lua/?.lua;" .. package.path
''
+ pkgs.lib.readFile ./config/init.lua
+ ''
EOF
'';
packages.plugins = with pkgs.vimPlugins; {
start = with pkgs.vimPlugins; [
telescope-nvim telescope-nvim
]; vim-commentary
vim-surround
toggleterm-nvim
targets-vim
indent-blankline-nvim
vim-go
vim-nix
nvim-treesitter-textobjects
leap-nvim
(nvim-treesitter.withPlugins
(
plugins: with plugins; [
tree-sitter-bash
tree-sitter-c
tree-sitter-dockerfile
tree-sitter-go
tree-sitter-javascript
tree-sitter-json
tree-sitter-lua
tree-sitter-nix
tree-sitter-php
tree-sitter-python
tree-sitter-yaml
]
)
)
];
};
}; };
}; };
}; apps.iofqvim = flake-utils.lib.mkApp {
apps.iofqvim = flake-utils.lib.mkApp { drv = packages.iofqvim;
drv = packages.iofqvim; name = "iofqvim";
name = "iofqvim"; exePath = "/bin/nvim";
exePath = "/bin/nvim"; };
}; apps.default = apps.iofqvim;
apps.default = apps.iofqvim; packages.default = packages.iofqvim;
packages.default = packages.iofqvim; });
}); }
}

1
result
View file

@ -1 +0,0 @@
/nix/store/vwg8csg6j9swzam3pwa6r391dpzqmmcd-neovim-0.9.0