From 9cd012f2e2c427eb36dba68b6a36df24a8e95d18 Mon Sep 17 00:00:00 2001 From: Hung Date: Sun, 4 Jun 2023 20:17:13 -0700 Subject: [PATCH] feat: less init.lua, more neovim.nix along with docs on shell setup --- flake.lock | 84 +++++++++++++++++++++++---- native_configs/neovim/init.lua | 62 +++++++++----------- nix-conf/home-manager/base/neovim.nix | 54 +++++++++++++++++ nix-conf/home-manager/base/shells.nix | 7 ++- nix-conf/home-manager/flake.lock | 36 ++++++------ nix-conf/home-manager/overlays.nix | 1 - 6 files changed, 180 insertions(+), 64 deletions(-) diff --git a/flake.lock b/flake.lock index f99bd80..ecaa208 100644 --- a/flake.lock +++ b/flake.lock @@ -145,7 +145,7 @@ }, "fenix": { "inputs": { - "nixpkgs": "nixpkgs_5", + "nixpkgs": "nixpkgs_6", "rust-analyzer-src": "rust-analyzer-src" }, "locked": { @@ -268,6 +268,28 @@ "type": "github" } }, + "haumea_3": { + "inputs": { + "nixpkgs": [ + "std", + "paisano", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1681176209, + "narHash": "sha256-bJLDun6esIyWtwRVXcsgzGbh4UKu8wJDrPgykqPyzmg=", + "owner": "nix-community", + "repo": "haumea", + "rev": "b915b66b27da3a595d77b139e945bb0a2fcac926", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "haumea", + "type": "github" + } + }, "hive": { "inputs": { "colmena": "colmena", @@ -381,6 +403,29 @@ "type": "github" } }, + "namaka_2": { + "inputs": { + "haumea": [ + "std", + "paisano", + "haumea" + ], + "nixpkgs": "nixpkgs_5" + }, + "locked": { + "lastModified": 1681604203, + "narHash": "sha256-oA/fW/85GmSNprghgAnZi0XeVMvW9xVuCYprzPw2hz0=", + "owner": "nix-community", + "repo": "namaka", + "rev": "1550ddc025334cff2e8ec9021256473b2ffb27e5", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "namaka", + "type": "github" + } + }, "nixago": { "inputs": { "flake-utils": [ @@ -459,11 +504,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1685168767, - "narHash": "sha256-wQgnxz0PdqbyKKpsWl/RU8T8QhJQcHfeC6lh1xRUTfk=", + "lastModified": 1685655444, + "narHash": "sha256-6EujQNAeaUkWvpEZZcVF8qSfQrNVWFNNGbUJxv/A5a8=", "owner": "nixos", "repo": "nixpkgs", - "rev": "e10802309bf9ae351eb27002c85cfdeb1be3b262", + "rev": "e635192892f5abbc2289eaac3a73cdb249abaefd", "type": "github" }, "original": { @@ -490,6 +535,22 @@ } }, "nixpkgs_5": { + "locked": { + "lastModified": 1680758185, + "narHash": "sha256-sCVWwfnk7zEX8Z+OItiH+pcSklrlsLZ4TJTtnxAYREw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "0e19daa510e47a40e06257e205965f3b96ce0ac9", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_6": { "locked": { "lastModified": 1677063315, "narHash": "sha256-qiB4ajTeAOVnVSAwCNEEkoybrAlA+cpeiBxLobHndE8=", @@ -634,6 +695,8 @@ }, "paisano_2": { "inputs": { + "haumea": "haumea_3", + "namaka": "namaka_2", "nixpkgs": [ "std", "nixpkgs" @@ -645,15 +708,16 @@ ] }, "locked": { - "lastModified": 1678949904, - "narHash": "sha256-oAoF66hYYz1RPh3lEwb9/4e4iyBAfTbQKZRRQ8gP0Ds=", + "lastModified": 1685757649, + "narHash": "sha256-gu21uo35i5OguZ5laGpqIFgVRcowbjvLn2mxSyNKZfQ=", "owner": "paisano-nix", "repo": "core", - "rev": "88f2aff10a5064551d1d4cb86800d17084489ce3", + "rev": "db53b8a8e2e3e557bf5ec5842b7a52ee5de04e87", "type": "github" }, "original": { "owner": "paisano-nix", + "ref": "0.1.0", "repo": "core", "type": "github" } @@ -740,11 +804,11 @@ "yants": "yants_2" }, "locked": { - "lastModified": 1684882168, - "narHash": "sha256-Yu1yw1sPWZsXe7BX7HaHg+O8fWKHCpy/AwgGfBdhivw=", + "lastModified": 1685759602, + "narHash": "sha256-aEIGXP3RecgVQ0qEsRM+OuYrY4GYzq7mmlVjpO+SOuo=", "owner": "divnix", "repo": "std", - "rev": "959f54d6698ff7fea01e4e6d8e5d7d95fcf66844", + "rev": "1607dab0469ac89ca6727a1cadde8bce3a958438", "type": "github" }, "original": { diff --git a/native_configs/neovim/init.lua b/native_configs/neovim/init.lua index 7db0368..45132dc 100644 --- a/native_configs/neovim/init.lua +++ b/native_configs/neovim/init.lua @@ -1,5 +1,4 @@ --- What: Mono-file nvim configuration file --- Why: Easy to see through everything without needing to navigate thru files +-- What: Mono-file nvim configuration file Why: Easy to see through everything without needing to navigate thru files -- Features: -- - LSP -- - Auto-complete (in insert mode: ctrl-space, navigate w/ Tab+S-Tab, confirm: Enter) @@ -25,13 +24,13 @@ local Plug = vim.fn['plug#'] vim.call('plug#begin') -- libs and dependencies -Plug('nvim-lua/plenary.nvim') -- The base of all plugins +-- Plug('nvim-lua/plenary.nvim') -- The base of all plugins -- plugins -Plug('tjdevries/nlua.nvim') -- adds symbols of vim stuffs in init.lua -Plug('nvim-treesitter/nvim-treesitter') -- language parser engine for highlighting -Plug('nvim-treesitter/nvim-treesitter-textobjects') -- more text objects -Plug('nvim-telescope/telescope.nvim', { branch = '0.1.x' }) -- file browser +-- Plug('tjdevries/nlua.nvim') -- adds symbols of vim stuffs in init.lua +-- Plug('nvim-treesitter/nvim-treesitter') -- language parser engine for highlighting +-- Plug('nvim-treesitter/nvim-treesitter-textobjects') -- more text objects +-- Plug('nvim-telescope/telescope.nvim', { branch = '0.1.x' }) -- file browser -- TODO: this might need to be taken extra care in our Nix config -- What this Plug declaration means is this repo needs to be built on our running environment -- ----- @@ -41,32 +40,32 @@ Plug('nvim-telescope/telescope.nvim', { branch = '0.1.x' }) -- file browser -- - Make sure that if we run `make` at first Plug run, that `make` is idempotent -- OR -- Make sure that Plug does not run `make` and use the output it needs -Plug('nvim-telescope/telescope-fzf-native.nvim', - { ['do'] = 'make >> /tmp/log 2>&1' }) -Plug('nvim-telescope/telescope-file-browser.nvim') +-- Plug('nvim-telescope/telescope-fzf-native.nvim', +-- { ['do'] = 'make >> /tmp/log 2>&1' }) +-- Plug('nvim-telescope/telescope-file-browser.nvim') -- cmp: auto-complete/suggestions -Plug('neovim/nvim-lspconfig') -- built-in LSP configurations -Plug('hrsh7th/cmp-nvim-lsp') -Plug('hrsh7th/cmp-path') -Plug('hrsh7th/cmp-buffer') -Plug('hrsh7th/cmp-cmdline') -Plug('hrsh7th/nvim-cmp') -Plug('onsails/lspkind-nvim') +-- Plug('neovim/nvim-lspconfig') -- built-in LSP configurations +-- Plug('hrsh7th/cmp-nvim-lsp') +-- Plug('hrsh7th/cmp-path') +-- Plug('hrsh7th/cmp-buffer') +-- Plug('hrsh7th/cmp-cmdline') +-- Plug('hrsh7th/nvim-cmp') +-- Plug('onsails/lspkind-nvim') Plug('yioneko/nvim-yati', { tag = '*' }) -- copium: fix Python indent auto-correct from smart-indent Plug('nathanalderson/yang.vim') -- Plug('tzachar/cmp-tabnine', { ['do'] = './install.sh' }) -- DevExp -Plug('windwp/nvim-autopairs') -- matches pairs like [] (),... -Plug('windwp/nvim-ts-autotag') -- matches tags hello -Plug('NMAC427/guess-indent.nvim') -- guesses the indentation of an opened buffer +-- Plug('windwp/nvim-autopairs') -- matches pairs like [] (),... +-- Plug('windwp/nvim-ts-autotag') -- matches tags hello +-- Plug('NMAC427/guess-indent.nvim') -- guesses the indentation of an opened buffer Plug('numToStr/Comment.nvim') -- "gc" to comment visual regions/lines Plug('lewis6991/gitsigns.nvim') -- add git info to sign columns Plug('tpope/vim-fugitive') -- git commands in nvim Plug('williamboman/mason.nvim') -- LSP, debuggers,... package manager Plug('williamboman/mason-lspconfig.nvim') -- lsp config for mason -Plug('ThePrimeagen/harpoon') -- 1-click through marked files per project +-- Plug('ThePrimeagen/harpoon') -- 1-click through marked files per project Plug('TimUntersberger/neogit') -- Easy-to-see git status Plug('folke/trouble.nvim') -- File-grouped workspace diagnostics Plug('tpope/vim-dispatch') -- Allows quick build/compile/test vim commands @@ -79,7 +78,7 @@ Plug('simrat39/rust-tools.nvim') -- config rust-analyzer and nvim integ -- UI & colorscheme Plug('simrat39/inlay-hints.nvim') -- type-hints with pseudo-virtual texts -Plug('gruvbox-community/gruvbox') -- theme provider +-- Plug('gruvbox-community/gruvbox') -- theme provider Plug('nvim-lualine/lualine.nvim') -- fancy status line Plug('lukas-reineke/indent-blankline.nvim') -- identation lines on blank lines Plug('kyazdani42/nvim-web-devicons') -- icons for folder and filetypes @@ -90,14 +89,14 @@ Plug('folke/todo-comments.nvim') -- Highlights TODO Plug('nvim-treesitter/nvim-treesitter-context') -- Top one-liner context of func/class scope Plug('nvim-treesitter/playground') -- Sees Treesitter AST - less hair pulling, more PRs Plug('saadparwaiz1/cmp_luasnip') -- snippet engine -Plug('L3MON4D3/LuaSnip') -- snippet engine -Plug('mickael-menu/zk-nvim') -- Zettelkasten +-- Plug('L3MON4D3/LuaSnip') -- snippet engine +-- Plug('mickael-menu/zk-nvim') -- Zettelkasten -- Switch cases: -- `gsp` -> PascalCase (classes), `gsc` -> camelCase (Java), `gs_` -> snake_case (C/C++/Rust) -- `gsu` -> UPPER_CASE (CONSTs), `gsk` -> kebab-case (Clojure), `gsK` -> Title-Kebab-Case -- `gs.` -> dot.case (R) Plug('arthurxavierx/vim-caser') -- switch cases -Plug('pegasust/tsql.nvim') -- workspace code intelligence +Plug('~/local_repos/ts-ql') -- workspace code intelligence --------- vim.call('plug#end') @@ -361,12 +360,6 @@ require('nvim-treesitter.configs').setup { disable = { "nix" } }, indent = { enable = false }, - ensure_installed = { - 'tsx', 'toml', 'lua', 'typescript', 'rust', 'go', 'yaml', 'json', 'php', 'css', - 'python', 'prisma', 'html', "dockerfile", "c", "cpp", "hcl", "svelte", "astro", - "clojure", "fennel", "bash", "nix", "query", "nickel" - }, - sync_install = false, highlight = { enable = true, enable_vim_regex_highlighting = true, @@ -603,7 +596,7 @@ local capabilities = require('cmp_nvim_lsp').default_capabilities() -- }) -- default language servers local servers = { - 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'sumneko_lua', 'cmake', 'tailwindcss', 'prismals', + 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'lua_ls', 'cmake', 'tailwindcss', 'prismals', 'rnix', 'eslint', 'terraformls', 'tflint', 'svelte', 'astro', 'clojure_lsp', "bashls", 'yamlls', "ansiblels", "jsonls", "denols", "gopls", "nickel_ls", 'pylsp', } @@ -645,8 +638,8 @@ require('mason-lspconfig').setup_handlers({ capabilities = capabilities, } end, - ["sumneko_lua"] = function() - require('lspconfig').sumneko_lua.setup { + ["lua_ls"] = function() + require('lspconfig').lua_ls.setup { on_attach = on_attach, capabilities = capabilities, settings = { @@ -1040,3 +1033,4 @@ require('lualine').setup { } require('nvim-surround').setup {} +require('tsql').setup() diff --git a/nix-conf/home-manager/base/neovim.nix b/nix-conf/home-manager/base/neovim.nix index bdb4356..dbfae99 100644 --- a/nix-conf/home-manager/base/neovim.nix +++ b/nix-conf/home-manager/base/neovim.nix @@ -94,6 +94,60 @@ in # https://github.com/nix-community/home-manager/pull/3287 # extraConfig = builtins.readFile "${proj_root}/neovim/init.lua"; extraLuaConfig = (builtins.readFile "${proj_root.config.path}//neovim/init.lua"); + plugins = (let inherit (pkgs.vimPlugins) + plenary-nvim + + nvim-treesitter + nvim-treesitter-textobjects + nvim-treesitter-context + + telescope-fzf-native-nvim + telescope-file-browser-nvim + telescope-nvim + + nvim-lspconfig + + gruvbox-community + + neodev-nvim + + cmp-nvim-lsp + cmp-path + cmp-buffer + cmp-cmdline + nvim-cmp + + lspkind-nvim + nvim-autopairs + nvim-ts-autotag + guess-indent-nvim + harpoon + zk-nvim + luasnip + ; in [ + plenary-nvim + nvim-treesitter.withAllGrammars + nvim-treesitter-textobjects + telescope-fzf-native-nvim + telescope-file-browser-nvim + telescope-nvim + nvim-lspconfig + gruvbox-community + neodev-nvim + cmp-nvim-lsp + cmp-path + cmp-buffer + cmp-cmdline + nvim-cmp + lspkind-nvim + nvim-autopairs + nvim-ts-autotag + guess-indent-nvim + harpoon + zk-nvim + luasnip + nvim-treesitter-context + ]); }; # home.packages = nvim_pkgs; }; diff --git a/nix-conf/home-manager/base/shells.nix b/nix-conf/home-manager/base/shells.nix index 16faf76..36b293e 100644 --- a/nix-conf/home-manager/base/shells.nix +++ b/nix-conf/home-manager/base/shells.nix @@ -1,5 +1,5 @@ # Configurations for shell stuffs. -# Should probably be decoupled even more +# Should probably be decoupled even more for each feature { config , proj_root , myLib @@ -59,14 +59,17 @@ in xdg.configFile."tmux/tmux.conf".text = myLib.mkOrder 600 '' set -g status-right '#{cpu_bg_color} CPU: #{cpu_icon} #{cpu_percentage} | %a %h-%d %H:%M ' ''; + # Colored ls programs.exa = { enable = true; enableAliases = true; }; + # Make the shell look beautiful programs.starship = { enable = true; enableZshIntegration = true; }; + # Fuzzy finder. `fzf` for TUI, `fzf -f ''` for UNIX piping programs.fzf.enable = true; programs.bash = { enable = true; @@ -99,6 +102,8 @@ in ]; }; sessionVariables = { + # Vim mode on the terminal + # VI_MODE_RESET_PROMPT_ON_MODE_CHANGE = true; # VI_MODE_SET_CURSOR = true; # ZVM_VI_ESCAPE_BINDKEY = ""; diff --git a/nix-conf/home-manager/flake.lock b/nix-conf/home-manager/flake.lock index 26e6774..9cf8b49 100644 --- a/nix-conf/home-manager/flake.lock +++ b/nix-conf/home-manager/flake.lock @@ -423,11 +423,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1681202837, - "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "lastModified": 1685518550, + "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", "owner": "numtide", "repo": "flake-utils", - "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", "type": "github" }, "original": { @@ -803,11 +803,11 @@ ] }, "locked": { - "lastModified": 1685189510, - "narHash": "sha256-Hq5WF7zIixojPgvhgcd6MBvywwycVZ9wpK/8ogOyoaA=", + "lastModified": 1685833925, + "narHash": "sha256-KCo8QT/DtM4pSTQDWFOhVP7MDzwi0wb2ZlxhgjEwXtM=", "owner": "nix-community", "repo": "home-manager", - "rev": "2d963854ae2499193c0c72fd67435fee34d3e4fd", + "rev": "bffc49ffb255f213d2f902043da37b3016450f4a", "type": "github" }, "original": { @@ -938,11 +938,11 @@ "topiary": "topiary" }, "locked": { - "lastModified": 1685111201, - "narHash": "sha256-WiaWxL1mBvHjOWGfC082zj/Nd1aaJt+Ga+KuzPQZ5dk=", + "lastModified": 1685719780, + "narHash": "sha256-igcKtuS1p63O3JDo3qIH4T53hK66K+QQNe+bo+D9qZI=", "owner": "tweag", "repo": "nickel", - "rev": "afdaff57cec860b27e9cdab79fafc2ee724b0cff", + "rev": "651ffdbc76e0314d693f4818812be3e2b100f626", "type": "github" }, "original": { @@ -1022,11 +1022,11 @@ ] }, "locked": { - "lastModified": 1683638468, - "narHash": "sha256-tQEaGZfZ2Hpw+XIVEHaJ8FaF1yNQyMDDhUyIQ7LTIEg=", + "lastModified": 1685764721, + "narHash": "sha256-CIy1iwQTEKfZRrid4gBLA+r/LPGA9IUFo0lKJVyECGI=", "owner": "mic92", "repo": "nix-index-database", - "rev": "219067a5e3cf4b9581c8b4fcfc59ecd5af953d07", + "rev": "669ca1f2e2bc401abab6b837ae9c51503edc9b49", "type": "github" }, "original": { @@ -1182,11 +1182,11 @@ }, "nixpkgs_12": { "locked": { - "lastModified": 1685168767, - "narHash": "sha256-wQgnxz0PdqbyKKpsWl/RU8T8QhJQcHfeC6lh1xRUTfk=", + "lastModified": 1685655444, + "narHash": "sha256-6EujQNAeaUkWvpEZZcVF8qSfQrNVWFNNGbUJxv/A5a8=", "owner": "nixos", "repo": "nixpkgs", - "rev": "e10802309bf9ae351eb27002c85cfdeb1be3b262", + "rev": "e635192892f5abbc2289eaac3a73cdb249abaefd", "type": "github" }, "original": { @@ -1753,11 +1753,11 @@ "nixpkgs": "nixpkgs_13" }, "locked": { - "lastModified": 1685240871, - "narHash": "sha256-bOCbP0lWTjhmrPcdyuFD/yx/38CKkzC2TNXmBzZSLJA=", + "lastModified": 1685846256, + "narHash": "sha256-G4aYK4VqlMHImvZ0lUnLHw1A+Cx28T0sBMvAKZBcGpk=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "aa1b08de9ca770534ad750dccc70cebd95c15e26", + "rev": "1ef3c6de6127a1cba94cc5492cdde52e33d06ea4", "type": "github" }, "original": { diff --git a/nix-conf/home-manager/overlays.nix b/nix-conf/home-manager/overlays.nix index 4f08827..c711e6a 100644 --- a/nix-conf/home-manager/overlays.nix +++ b/nix-conf/home-manager/overlays.nix @@ -12,7 +12,6 @@ let # use python3.9, which works because of cython somehow? kpcli-py = final.poetry2nix.mkPoetryApplication { projectDir = flake_input.kpcli-py; - python = final.python39; overrides = final.poetry2nix.defaultPoetryOverrides.extend (self: super: { # tableformatter requires setuptools tableformatter = super.tableformatter.overridePythonAttrs (