diff --git a/bash/default.nix b/bash/default.nix new file mode 100644 index 0000000..19b3a93 --- /dev/null +++ b/bash/default.nix @@ -0,0 +1,13 @@ +{ config, pkgs, ... }: + +{ + programs.bash = { + enable = true; + profileExtra ='' + set -o vi + [ ! -z $TMUX ] || tmux a || tmux + neofetch + ''; + }; + +} diff --git a/extraConfig.tmux b/extraConfig.tmux deleted file mode 100644 index 268b786..0000000 --- a/extraConfig.tmux +++ /dev/null @@ -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}" diff --git a/extraConfig.vim b/extraConfig.vim deleted file mode 100644 index b680018..0000000 --- a/extraConfig.vim +++ /dev/null @@ -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 :leftabove 25vs:e . - -" 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 to trigger completion. -inoremap 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 ' to make sure tab is not mapped by -" other plugin before putting this into your config. -inoremap - \ coc#pum#visible() ? coc#pum#next(1) : - \ CheckBackspace() ? "\" : - \ coc#refresh() -inoremap coc#pum#visible() ? coc#pum#prev(1) : "\" - -" Make to accept selected completion item or notify coc.nvim to format -" u breaks current undo, please make your own choice. -inoremap coc#pum#visible() ? coc#pum#confirm() - \: "\u\\=coc#on_enter()\" - -function! CheckBackspace() abort - let col = col('.') - 1 - return !col || getline('.')[col - 1] =~# '\s' -endfunction diff --git a/git/default.nix b/git/default.nix new file mode 100644 index 0000000..078e850 --- /dev/null +++ b/git/default.nix @@ -0,0 +1,10 @@ +{ config, pkgs, ... }: + +{ + programs.git = { + enable = true; + userName = "Evan Reichard"; + userEmail = "evan@reichard.io"; + }; + +} diff --git a/home.nix b/home.nix index e1a1a7b..6ea0c0a 100644 --- a/home.nix +++ b/home.nix @@ -2,6 +2,15 @@ { + imports = [ + ./bash + ./git + ./nvim + ./powerline + ./readline + ./tmux + ]; + # Home Manager Config home.username = "evanreichard"; home.homeDirectory = "/Users/evanreichard"; @@ -9,133 +18,20 @@ programs.home-manager.enable = true; # Global Packages - home.packages = [ - pkgs.bashInteractive - pkgs.htop - pkgs.k9s - pkgs.kubectl - pkgs.mosh - pkgs.neofetch + home.packages = with pkgs; [ + bashInteractive + htop + k9s + kubectl + mosh + neofetch + nerdfonts + python311 + tldr ]; # Other Programs programs.jq.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" - ]; - }; } - diff --git a/nvim/config/lua/aerial-config.lua b/nvim/config/lua/aerial-config.lua new file mode 100644 index 0000000..21851a2 --- /dev/null +++ b/nvim/config/lua/aerial-config.lua @@ -0,0 +1,8 @@ +require('aerial').setup({ + on_attach = function(bufnr) + vim.keymap.set('n', '{', 'AerialPrev', {buffer = bufnr}) + vim.keymap.set('n', '}', 'AerialNext', {buffer = bufnr}) + end +}) + +vim.keymap.set('n', 'a', 'AerialToggle!') diff --git a/nvim/config/lua/autopairs-config.lua b/nvim/config/lua/autopairs-config.lua new file mode 100644 index 0000000..4de6add --- /dev/null +++ b/nvim/config/lua/autopairs-config.lua @@ -0,0 +1 @@ +require("nvim-autopairs").setup() diff --git a/nvim/config/lua/base.lua b/nvim/config/lua/base.lua new file mode 100644 index 0000000..4079f46 --- /dev/null +++ b/nvim/config/lua/base.lua @@ -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', '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', 'q', vim.diagnostic.setloclist, opts) diff --git a/nvim/config/lua/cmp-config.lua b/nvim/config/lua/cmp-config.lua new file mode 100644 index 0000000..823ff04 --- /dev/null +++ b/nvim/config/lua/cmp-config.lua @@ -0,0 +1,49 @@ +local cmp = require'cmp' + +cmp.setup({ + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + [''] = 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() +) diff --git a/nvim/config/lua/comment-config.lua b/nvim/config/lua/comment-config.lua new file mode 100644 index 0000000..a844323 --- /dev/null +++ b/nvim/config/lua/comment-config.lua @@ -0,0 +1 @@ +require('Comment').setup() diff --git a/nvim/config/lua/init.lua b/nvim/config/lua/init.lua new file mode 100644 index 0000000..2409f71 --- /dev/null +++ b/nvim/config/lua/init.lua @@ -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') diff --git a/nvim/config/lua/lsp-config.lua b/nvim/config/lua/lsp-config.lua new file mode 100644 index 0000000..10b04cc --- /dev/null +++ b/nvim/config/lua/lsp-config.lua @@ -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 + 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', '', vim.lsp.buf.signature_help, bufopts) + vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, bufopts) + vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, bufopts) + vim.keymap.set('n', 'wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, bufopts) + vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, bufopts) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, bufopts) + vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, bufopts) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) + vim.keymap.set('n', '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, + } +} diff --git a/nvim/config/lua/lsp-lines-config.lua b/nvim/config/lua/lsp-lines-config.lua new file mode 100644 index 0000000..372aaf5 --- /dev/null +++ b/nvim/config/lua/lsp-lines-config.lua @@ -0,0 +1 @@ +require("lsp_lines").setup() diff --git a/nvim/config/lua/noice-config.lua b/nvim/config/lua/noice-config.lua new file mode 100644 index 0000000..d3050be --- /dev/null +++ b/nvim/config/lua/noice-config.lua @@ -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 + }, +}) diff --git a/nvim/config/lua/numb-config.lua b/nvim/config/lua/numb-config.lua new file mode 100644 index 0000000..e3b245e --- /dev/null +++ b/nvim/config/lua/numb-config.lua @@ -0,0 +1 @@ +require('numb').setup() diff --git a/nvim/config/lua/nvim-tree-config.lua b/nvim/config/lua/nvim-tree-config.lua new file mode 100644 index 0000000..df3b05c --- /dev/null +++ b/nvim/config/lua/nvim-tree-config.lua @@ -0,0 +1 @@ +require("nvim-tree").setup() diff --git a/nvim/config/lua/telescope-config.lua b/nvim/config/lua/telescope-config.lua new file mode 100644 index 0000000..fadf3d4 --- /dev/null +++ b/nvim/config/lua/telescope-config.lua @@ -0,0 +1,7 @@ +require('telescope').setup() + +local builtin = require('telescope.builtin') +vim.keymap.set('n', 'ff', builtin.find_files, {}) +vim.keymap.set('n', 'fg', builtin.live_grep, {}) +vim.keymap.set('n', 'fb', builtin.buffers, {}) +vim.keymap.set('n', 'fh', builtin.help_tags, {}) diff --git a/nvim/default.nix b/nvim/default.nix new file mode 100644 index 0000000..d7181fe --- /dev/null +++ b/nvim/default.nix @@ -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 + ''; + + }; +} diff --git a/powerline/default.nix b/powerline/default.nix new file mode 100644 index 0000000..d7962eb --- /dev/null +++ b/powerline/default.nix @@ -0,0 +1,14 @@ +{ config, pkgs, ... }: + +{ + programs.powerline-go = { + enable = true; + modules = [ + "host" + "cwd" + "git" + "docker" + "venv" + ]; + }; +} diff --git a/readline/default.nix b/readline/default.nix new file mode 100644 index 0000000..a7be5bf --- /dev/null +++ b/readline/default.nix @@ -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 + ''; + }; + +} diff --git a/tmux/default.nix b/tmux/default.nix new file mode 100644 index 0000000..3d7a7c8 --- /dev/null +++ b/tmux/default.nix @@ -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" + ''; + }; +}