nix refactor

This commit is contained in:
Evan Reichard 2022-11-25 11:30:22 -05:00
parent 6d3b323ab1
commit eeefab3584
21 changed files with 420 additions and 186 deletions

13
bash/default.nix Normal file
View File

@ -0,0 +1,13 @@
{ config, pkgs, ... }:
{
programs.bash = {
enable = true;
profileExtra =''
set -o vi
[ ! -z $TMUX ] || tmux a || tmux
neofetch
'';
};
}

View File

@ -1,9 +0,0 @@
# VIM, Prefix, Renumber
setw -g mode-keys vi
set-option -g prefix C-t
set-option -g renumber-windows on
# Maintain Directory
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"

View File

@ -1,54 +0,0 @@
" lightline config
let g:lightline = {
\ 'separator': { 'left': "\ue0b0", 'right': "\ue0b2" },
\ 'subseparator': { 'left': "\ue0b1", 'right': "\ue0b3" }
\ }
" set nowrap, line numbers, hightlight search
set nowrap
set nu
set hlsearch
set shiftwidth=2
" set fold settings
set foldmethod=indent
set foldnestmax=10
set foldlevel=2
" synchronize with system clipboard
set clipboard=unnamed
" remap shift-enter to fire up the sidebar
" the same remap as above - may be necessary in some distros
nnoremap <silent> <C-M> :leftabove 25vs<CR>:e .<CR>
" View *.hex files in hex
au BufReadPost *.hex silent %!xxd
" Always show the signcolumn, otherwise it would shift the text each time
" diagnostics appear/become resolved.
set signcolumn=yes
" Use <c-space> to trigger completion.
inoremap <silent><expr> <c-space> coc#refresh()
" Use tab for trigger completion with characters ahead and navigate.
" NOTE: There's always complete item selected by default, you may want to enable
" no select by `"suggest.noselect": true` in your configuration file.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config.
inoremap <silent><expr> <TAB>
\ coc#pum#visible() ? coc#pum#next(1) :
\ CheckBackspace() ? "\<Tab>" :
\ coc#refresh()
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
" Make <CR> to accept selected completion item or notify coc.nvim to format
" <C-g>u breaks current undo, please make your own choice.
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction

10
git/default.nix Normal file
View File

@ -0,0 +1,10 @@
{ config, pkgs, ... }:
{
programs.git = {
enable = true;
userName = "Evan Reichard";
userEmail = "evan@reichard.io";
};
}

142
home.nix
View File

@ -2,6 +2,15 @@
{ {
imports = [
./bash
./git
./nvim
./powerline
./readline
./tmux
];
# Home Manager Config # Home Manager Config
home.username = "evanreichard"; home.username = "evanreichard";
home.homeDirectory = "/Users/evanreichard"; home.homeDirectory = "/Users/evanreichard";
@ -9,133 +18,20 @@
programs.home-manager.enable = true; programs.home-manager.enable = true;
# Global Packages # Global Packages
home.packages = [ home.packages = with pkgs; [
pkgs.bashInteractive bashInteractive
pkgs.htop htop
pkgs.k9s k9s
pkgs.kubectl kubectl
pkgs.mosh mosh
pkgs.neofetch neofetch
nerdfonts
python311
tldr
]; ];
# Other Programs # Other Programs
programs.jq.enable = true; programs.jq.enable = true;
programs.pandoc.enable = true; programs.pandoc.enable = true;
# ----------------------
# --------- git --------
# ----------------------
programs.git = {
enable = true;
userName = "Evan Reichard";
userEmail = "evan@reichard.io";
};
# ----------------------
# ------ readline ------
# ----------------------
programs.readline = {
enable = true;
extraConfig = ''
# Show Prompt
set show-mode-in-prompt on
# Approximate VIM Dracula Colors
set vi-ins-mode-string \1\e[01;38;5;23;48;5;231m\2 INS \1\e[38;5;231;48;5;238m\2\1\e[0m\2
set vi-cmd-mode-string \1\e[01;38;5;22;48;5;148m\2 CMD \1\e[38;5;148;48;5;238m\2\1\e[0m\2
'';
};
# ----------------------
# -------- bash --------
# ----------------------
programs.bash = {
enable = true;
profileExtra =''
set -o vi
[ ! -z $TMUX ] || tmux a || tmux
neofetch
'';
};
# ----------------------
# -------- tmux --------
# ----------------------
programs.tmux = {
enable = true;
clock24 = true;
shell = "${pkgs.bashInteractive}/bin/bash";
plugins = with pkgs.tmuxPlugins; [
yank
cpu
resurrect
continuum
{
plugin = dracula;
extraConfig = ''
set -g @dracula-show-battery false
set -g @dracula-show-powerline true
set -g @dracula-refresh-rate 10
set -g @dracula-military-time true
set -g @dracula-plugins "battery cpu-usage ram-usage time"
'';
} }
];
extraConfig = builtins.readFile ./extraConfig.tmux;
};
# ----------------------
# ------- neovim -------
# ----------------------
programs.neovim = {
enable = true;
viAlias = true;
vimAlias = true;
withNodeJs = true;
withPython3 = true;
plugins = with pkgs.vimPlugins; [
coc-eslint
coc-json
coc-pyright
coc-yaml
dracula-vim
lightline-vim
vim-nix
];
coc = {
enable = true;
package = pkgs.vimUtils.buildVimPluginFrom2Nix {
pname = "coc.nvim";
version = "2022-11-03";
src = pkgs.fetchFromGitHub {
owner = "neoclide";
repo = "coc.nvim";
rev = "5f52e41be1ff19ce1f1bd3307144e7d96703b7fd";
sha256 = "0nm8jgdgxbdlvcpl12fs2fgxww5nizjpqd2ywm2n7ca0lsjpqcx0";
};
meta.homepage = "https://github.com/neoclide/coc.nvim/";
};
};
extraConfig = builtins.readFile ./extraConfig.vim;
};
# ----------------------
# ------ powerline -----
# ----------------------
programs.powerline-go = {
enable = true;
modules = [
"host"
"cwd"
"git"
"docker"
"venv"
];
};
}

View File

@ -0,0 +1,8 @@
require('aerial').setup({
on_attach = function(bufnr)
vim.keymap.set('n', '{', '<cmd>AerialPrev<CR>', {buffer = bufnr})
vim.keymap.set('n', '}', '<cmd>AerialNext<CR>', {buffer = bufnr})
end
})
vim.keymap.set('n', '<leader>a', '<cmd>AerialToggle!<CR>')

View File

@ -0,0 +1 @@
require("nvim-autopairs").setup()

50
nvim/config/lua/base.lua Normal file
View File

@ -0,0 +1,50 @@
-- Disable NetRW
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
-- Set Term Colors
vim.opt.termguicolors = true
-- Synchronize with system clipboard
vim.opt.clipboard = "unnamed"
-- Always show the signcolumn
vim.opt.signcolumn = "yes"
-- Set nowrap, line numbers, hightlight search
vim.opt.wrap = false
vim.opt.nu = true
vim.opt.hlsearch = true
vim.opt.shiftwidth = 2
-- Set fold settings
vim.opt.foldmethod = "indent"
vim.opt.foldnestmax = 10
vim.opt.foldlevel = 2
-- Lightline config
vim.g['lightline'] = {
colorscheme = 'embark',
separator = {
left = "\u{e0b0}",
right = "\u{e0b2}"
},
subseparator = {
left = "\u{e0b1}",
right = "\u{e0b3}"
}
}
-- Set Color Scheme
vim.cmd('colorscheme embark')
vim.diagnostic.config({
virtual_text = false,
})
-- Mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
local opts = { noremap=true, silent=true }
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)

View File

@ -0,0 +1,49 @@
local cmp = require'cmp'
cmp.setup({
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 = 'buffer' },
})
})
-- Set configuration for specific filetype.
cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{ name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it.
}, {
{ name = 'buffer' },
})
})
-- -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline({ '/', '?' }, {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = 'buffer' }
}
})
-- -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
cmp.event:on(
'confirm_done',
cmp_autopairs.on_confirm_done()
)

View File

@ -0,0 +1 @@
require('Comment').setup()

11
nvim/config/lua/init.lua Normal file
View File

@ -0,0 +1,11 @@
require('aerial-config')
require('autopairs-config')
require('base')
require('cmp-config')
require('comment-config')
require('lsp-config')
require('lsp-lines-config')
require('noice-config')
require('numb-config')
require('nvim-tree-config')
require('telescope-config')

View File

@ -0,0 +1,60 @@
local nix_vars = require("nix-vars")
local nvim_lsp = require('lspconfig')
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
-- Enable completion triggered by <c-x><c-o>
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local bufopts = { noremap=true, silent=true, buffer=bufnr }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, bufopts)
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
vim.keymap.set('n', '<space>f', function() vim.lsp.buf.format { async = true } end, bufopts)
end
local lsp_flags = {
debounce_text_changes = 150,
}
local capabilities = require('cmp_nvim_lsp').default_capabilities()
nvim_lsp.pyright.setup{
on_attach = on_attach,
flags = lsp_flags,
capabilities = capabilities,
}
nvim_lsp.html.setup{
on_attach = on_attach,
flags = lsp_flags,
capabilities = capabilities,
cmd = {
nix_vars.htmlserver,
"--stdio",
}
}
nvim_lsp.tsserver.setup{
on_attach = on_attach,
flags = lsp_flags,
capabilities = capabilities,
cmd = {
nix_vars.tsserver,
"--stdio",
"--tsserver-path",
nix_vars.tslib,
}
}

View File

@ -0,0 +1 @@
require("lsp_lines").setup()

View File

@ -0,0 +1,17 @@
require("noice").setup()
require("noice").setup({
lsp = {
override = {
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
["vim.lsp.util.stylize_markdown"] = true,
["cmp.entry.get_documentation"] = true,
},
},
presets = {
-- bottom_search = false, -- use a classic bottom cmdline for search
command_palette = true, -- position the cmdline and popupmenu together
long_message_to_split = true, -- long messages will be sent to a split
inc_rename = false, -- enables an input dialog for inc-rename.nvim
lsp_doc_border = true, -- add a border to hover docs and signature help
},
})

View File

@ -0,0 +1 @@
require('numb').setup()

View File

@ -0,0 +1 @@
require("nvim-tree").setup()

View File

@ -0,0 +1,7 @@
require('telescope').setup()
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
vim.keymap.set('n', '<leader>fb', builtin.buffers, {})
vim.keymap.set('n', '<leader>fh', builtin.help_tags, {})

100
nvim/default.nix Normal file
View File

@ -0,0 +1,100 @@
{ config, pkgs, ... }:
{
programs.neovim = {
enable = true;
viAlias = true;
vimAlias = true;
withNodeJs = true;
withPython3 = true;
plugins = with pkgs.vimPlugins; [
# ------------------
# --- Completion ---
# ------------------
cmp-buffer # Buffer Word Completion
cmp-cmdline # Command Line Completion
cmp-nvim-lsp # Main LSP
cmp-path # Path Completion
cmp-vsnip # Snippets
lsp_lines-nvim # Inline Diagnostics
nvim-cmp # Completions
nvim-lspconfig # LSP Config
# ------------------
# ----- Helpers ----
# ------------------
aerial-nvim # Code Outline
comment-nvim # Code Comments
diffview-nvim # Diff View
numb-nvim # Peek / Jump to Lines
nvim-autopairs # Automatically Close Pairs (),[],{}
nvim-tree-lua # File Explorer
telescope-nvim # Fuzzy Finder
vim-nix # Nix Helpers
# ------------------
# --- Theme / UI ---
# ------------------
embark-vim # Theme
lightline-vim # Bottom Line
noice-nvim # UI Tweaks
nvim-web-devicons # Dev Icons
# ------------------
# --- Treesitter ---
# ------------------
(
nvim-treesitter.withPlugins (
plugins: with pkgs.tree-sitter-grammars; [
# tree-sitter-bash # Incompatibility (Prevents Noice Highlighting)
tree-sitter-lua
tree-sitter-markdown
tree-sitter-markdown-inline
tree-sitter-regex
tree-sitter-vim
]
)
)
];
extraPackages = with pkgs; [
# Telescope Dependencies
ripgrep
fd
# LSP Dependencies
nodePackages.pyright
nodePackages.typescript
nodePackages.typescript-language-server
nodePackages.vscode-html-languageserver-bin
];
extraConfig = ":luafile ~/.config/nvim/lua/init.lua";
};
xdg.configFile = {
# Copy Configuration
nvim = {
source = ./config;
recursive = true;
};
# Generate Nix Vars
"nvim/lua/nix-vars.lua".text = ''
local nix_vars = {
htmlserver = "${pkgs.nodePackages.vscode-html-languageserver-bin}/bin/html-languageserver",
tsserver = "${pkgs.nodePackages.typescript-language-server}/bin/typescript-language-server",
tslib = "${pkgs.nodePackages.typescript}/lib/node_modules/typescript/lib/",
}
return nix_vars
'';
};
}

14
powerline/default.nix Normal file
View File

@ -0,0 +1,14 @@
{ config, pkgs, ... }:
{
programs.powerline-go = {
enable = true;
modules = [
"host"
"cwd"
"git"
"docker"
"venv"
];
};
}

16
readline/default.nix Normal file
View File

@ -0,0 +1,16 @@
{ config, pkgs, ... }:
{
programs.readline = {
enable = true;
extraConfig = ''
# Show Prompt
set show-mode-in-prompt on
# Approximate VIM Dracula Colors
set vi-ins-mode-string \1\e[01;38;5;23;48;5;231m\2 INS \1\e[38;5;231;48;5;238m\2\1\e[0m\2
set vi-cmd-mode-string \1\e[01;38;5;22;48;5;148m\2 CMD \1\e[38;5;148;48;5;238m\2\1\e[0m\2
'';
};
}

41
tmux/default.nix Normal file
View File

@ -0,0 +1,41 @@
{ config, pkgs, ... }:
{
programs.tmux = {
enable = true;
clock24 = true;
shell = "${pkgs.bashInteractive}/bin/bash";
plugins = with pkgs.tmuxPlugins; [
yank
cpu
resurrect
continuum
{
plugin = dracula;
extraConfig = ''
set -g @dracula-show-battery false
set -g @dracula-show-powerline true
set -g @dracula-refresh-rate 10
set -g @dracula-military-time true
set -g @dracula-plugins "battery cpu-usage ram-usage time"
'';
}
];
extraConfig = ''
# VIM, Prefix, Renumber
setw -g mode-keys vi
set-option -g prefix C-t
set-option -g renumber-windows on
# Maintain Directory
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"
# Set Colors
# set -g default-terminal "screen-256color"
# set-option -ga terminal-overrides ",xterm-256color:Tc"
'';
};
}