Compare commits

..

3 Commits

Author SHA1 Message Date
Hung 7f0611d186 docs 2023-06-12 12:14:59 -07:00
Hung a6c979c659 feat: add couple more vim plugins via nixpkgs 2023-06-11 23:51:47 -07:00
Hung a5186b204c feat: idempotent installation with WPlug 2023-06-11 21:21:01 -07:00
13 changed files with 1179 additions and 142 deletions

View File

@ -78,3 +78,4 @@ fi
- Otherwise, consult [`gh-gist:meeech/a_help-osx-borked-my-nix.md`](https://gist.github.com/meeech/0b97a86f235d10bc4e2a1116eec38e7e) - Otherwise, consult [`gh-gist:meeech/a_help-osx-borked-my-nix.md`](https://gist.github.com/meeech/0b97a86f235d10bc4e2a1116eec38e7e)

View File

@ -28,7 +28,7 @@ documentations and defaults
- `nativeBuildInputs` is supposed to be built by a deployment machine (not target) - `nativeBuildInputs` is supposed to be built by a deployment machine (not target)
- `buildInputs` gives you access during runtime - `buildInputs` gives you access during runtime (if the package goes path build filter)
- `nativeBulidInputs` gives you access to packages during build time - `nativeBulidInputs` gives you access to packages during build time

169
docs/vim-plugins.md Normal file
View File

@ -0,0 +1,169 @@
# Vim Plugins
The current [`scripts/vim.dsl`](../scripts/vim.dsl) grabs the upstream supported vim plugins
onto a sqlite database to be stored in memory. We could perform some data exploration via this database
## Explore which plugins should be added to `neovim.nix`
Gather list of plugins need to be added. This can be done simply by adding
a print statement on `WPlug` in `../native_configs/neovim/init.lua` then run neovim
to collect it.
```lua
-- as of git://./dotfiles.git#a6c979c6
local function WPlug(plugin_path, ...)
local plugin_name = string.lower(plugin_path:match("/([^/]+)$"))
if not installed_plugins[plugin_name] then
-- NOTE: Add print statement to get which plugin is still being
-- plugged at runtime
print("Plugging "..plugin_path)
Plug(plugin_path, ...)
end
end
```
We can then use `vim_dsl.py`
```py
vp = VimPlugins(UPSTREAM_CSV)
need_install_plugins = """
tjdevries/nlua.nvim
yioneko/nvim-yati
nathanalderson/yang.vim
numToStr/Comment.nvim
lewis6991/gitsigns.nvim
tpope/vim-fugitive
williamboman/mason.nvim
williamboman/mason-lspconfig.nvim
TimUntersberger/neogit
folke/trouble.nvim
tpope/vim-dispatch
clojure-vim/vim-jack-in
radenling/vim-dispatch-neovim
gennaro-tedesco/nvim-jqx
kylechui/nvim-surround
simrat39/inlay-hints.nvim
gruvbox-community/gruvbox
nvim-lualine/lualine.nvim
lukas-reineke/indent-blankline.nvim
kyazdani42/nvim-web-devicons
m-demare/hlargs.nvim
folke/todo-comments.nvim
nvim-treesitter/playground
saadparwaiz1/cmp_luasnip
L3MON4D3/LuaSnip
arthurxavierx/vim-caser
~/local_repos/ts-ql
""".split()
need_install_plugins = [plugin.strip() for plugin in plugins_raw if plugin.strip()]
# Create the GitHub URL list
need_install_plugins_gh = [
f"https://github.com/{plugin}/".lower() for plugin in need_install_plugins if not plugin.startswith(("~", "."))]
# Get the values from the database
values = vp.query(f"SELECT LOWER(repo), alias from {vp.table_name()}")
# Check if the repo is in the list of plugins
need_install = [
vim_plugin_slug(alias) if alias else name_from_repo(repo) for repo, alias in values if repo in need_install_plugins_gh]
print("need_install", "\n".join(need_install))
# Check if the repo is not in the list
repos = [repo for repo, _ in values]
not_in_repo = [name_from_repo(gh) for gh in need_install_plugins_gh if gh not in repos]
print("not in repo", not_in_repo) # nvim-yati, yang-vim, Comment-nvim, inlay-hints-nvim, hlargs-nvim, vim-caser, gruvbox-community
```
This should print out
```
need_install
cmp_luasnip
comment-nvim
gitsigns-nvim
gruvbox-community
indent-blankline-nvim
lualine-nvim
luasnip
mason-lspconfig-nvim
mason-nvim
neogit
nlua-nvim
nvim-jqx
nvim-surround
nvim-web-devicons
playground
todo-comments-nvim
trouble-nvim
vim-dispatch
vim-dispatch-neovim
vim-fugitive
vim-jack-in
not in repo ['nvim-yati', 'yang-vim', 'inlay-hints-nvim', 'hlargs-nvim', 'vim-caser']
```
Given this list, we could safely add to `neovim.nix`
```nix
programs.neovim.plugins =
let inherit (pkgs.vimPlugins)
need_install
cmp_luasnip
comment-nvim
gitsigns-nvim
gruvbox-community
indent-blankline-nvim
lualine-nvim
luasnip
mason-lspconfig-nvim
mason-nvim
neogit
nlua-nvim
nvim-jqx
nvim-surround
nvim-web-devicons
playground
todo-comments-nvim
trouble-nvim
vim-dispatch
vim-dispatch-neovim
vim-fugitive
vim-jack-in
;in [
need_install
cmp_luasnip
comment-nvim
gitsigns-nvim
gruvbox-community
indent-blankline-nvim
lualine-nvim
luasnip
mason-lspconfig-nvim
mason-nvim
neogit
nlua-nvim
nvim-jqx
nvim-surround
nvim-web-devicons
playground
todo-comments-nvim
trouble-nvim
vim-dispatch
vim-dispatch-neovim
vim-fugitive
vim-jack-in
];
```
TODO:
- [ ] Source the plugins directly
- [ ] Add 'frozen' to each of these plugin
- [ ] Pin plugins separately from `neovim.nix`
- [ ] Find a better way to `inherit` with list comprehension
- [ ] Create alert & notification channel for this, ideally via Discord channel
- [ ] Even better, just put it in email with some labels
- [ ] Better end-to-end design that take even deeper account to gruvbox-community and such

View File

@ -301,11 +301,11 @@
"paisano": "paisano" "paisano": "paisano"
}, },
"locked": { "locked": {
"lastModified": 1682269418, "lastModified": 1686502488,
"narHash": "sha256-0fdUrQMkXMuK1/6D1Y+gbGXIWChiIRnlbYvo4dmNfVE=", "narHash": "sha256-sLSiDkU9oNpcl1QEge0xVviD7N87iVdrwl7l9i+6mxQ=",
"owner": "divnix", "owner": "divnix",
"repo": "hive", "repo": "hive",
"rev": "669cdfcf61823d33f11a4fe5ee1f3c34903f4eaa", "rev": "e8b46fa4d2917dfd456f3f040e9761262b4648d2",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -504,11 +504,11 @@
}, },
"nixpkgs_3": { "nixpkgs_3": {
"locked": { "locked": {
"lastModified": 1686020360, "lastModified": 1686501370,
"narHash": "sha256-Wee7lIlZ6DIZHHLiNxU5KdYZQl0iprENXa/czzI6Cj4=", "narHash": "sha256-G0WuM9fqTPRc2URKP9Lgi5nhZMqsfHGrdEbrLvAPJcg=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "4729ffac6fd12e26e5a8de002781ffc49b0e94b7", "rev": "75a5ebf473cd60148ba9aec0d219f72e5cf52519",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -804,11 +804,11 @@
"yants": "yants_2" "yants": "yants_2"
}, },
"locked": { "locked": {
"lastModified": 1686006649, "lastModified": 1686337240,
"narHash": "sha256-6sdvFtQyx7SZoki1MlO2+3Xns4jmR34FEjlXawQdwhk=", "narHash": "sha256-JedAsyUIbSIhVrRWSl0R3lSWemVWsHg0w3MuzW7h4tg=",
"owner": "divnix", "owner": "divnix",
"repo": "std", "repo": "std",
"rev": "d6bcee9c35fb4a905b51c39e4d5ca842e9a421eb", "rev": "1bd99cec90a5cee8575f45dbc193d6dd860a5f35",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@ -37,5 +37,6 @@
devShells = std.harvest [ [ "dotfiles" "devshells" ] ]; devShells = std.harvest [ [ "dotfiles" "devshells" ] ];
# nixosConfigurations = std.pick [ [ "dotfiles" "nixos" ] ]; # nixosConfigurations = std.pick [ [ "dotfiles" "nixos" ] ];
# homeConfigurations = std.pick [ [ "dotfiles" "home" ] ]; # homeConfigurations = std.pick [ [ "dotfiles" "home" ] ];
homeModules = std.pick [["repo" "home-modules"]];
}; };
} }

View File

@ -0,0 +1,721 @@
(vim.cmd "let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
let plug_path = data_dir . '/autoload/plug.vim'
if empty(glob(plug_path))
execute '!curl -fLo '.plug_path.' --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
execute 'so '.plug_path
endif
")
(local Plug (. vim.fn "plug#"))
(local installed-plugins {})
(each [_ path (ipairs (vim.api.nvim_list_runtime_paths))]
(local last-folder-start (path:find "/[^/]*$"))
(when last-folder-start
(local plugin-name (path:sub (+ last-folder-start 1)))
(tset installed-plugins plugin-name true)))
(fn WPlug [plugin-path ...]
(let [plugin-name (string.lower (plugin-path:match "/([^/]+)$"))]
(when (not (. installed-plugins plugin-name)) (Plug plugin-path ...))))
(vim.call "plug#begin")
(WPlug :tjdevries/nlua.nvim)
(WPlug :nvim-treesitter/nvim-treesitter)
(WPlug :nvim-treesitter/nvim-treesitter-textobjects)
(WPlug :nvim-telescope/telescope.nvim {:branch :0.1.x})
(WPlug :nvim-telescope/telescope-fzf-native.nvim {:do "make >> /tmp/log 2>&1"})
(WPlug :nvim-telescope/telescope-file-browser.nvim)
(WPlug :neovim/nvim-lspconfig)
(WPlug :hrsh7th/cmp-nvim-lsp)
(WPlug :hrsh7th/cmp-path)
(WPlug :hrsh7th/cmp-buffer)
(WPlug :hrsh7th/cmp-cmdline)
(WPlug :hrsh7th/nvim-cmp)
(WPlug :onsails/lspkind-nvim)
(WPlug :yioneko/nvim-yati {:tag "*"})
(WPlug :nathanalderson/yang.vim)
(WPlug :windwp/nvim-autopairs)
(WPlug :windwp/nvim-ts-autotag)
(WPlug :NMAC427/guess-indent.nvim)
(WPlug :j-hui/fidget.nvim)
(WPlug :numToStr/Comment.nvim)
(WPlug :lewis6991/gitsigns.nvim)
(WPlug :tpope/vim-fugitive)
(WPlug :williamboman/mason.nvim)
(WPlug :williamboman/mason-lspconfig.nvim)
(WPlug :ThePrimeagen/harpoon)
(WPlug :TimUntersberger/neogit)
(WPlug :folke/trouble.nvim)
(WPlug :tpope/vim-dispatch)
(WPlug :clojure-vim/vim-jack-in)
(WPlug :radenling/vim-dispatch-neovim)
(WPlug :gennaro-tedesco/nvim-jqx)
(WPlug :kylechui/nvim-surround)
(WPlug :simrat39/rust-tools.nvim)
(WPlug :simrat39/inlay-hints.nvim)
(WPlug :gruvbox-community/gruvbox)
(WPlug :nvim-lualine/lualine.nvim)
(WPlug :lukas-reineke/indent-blankline.nvim)
(WPlug :kyazdani42/nvim-web-devicons)
(WPlug :m-demare/hlargs.nvim)
(WPlug :folke/todo-comments.nvim)
(WPlug :nvim-treesitter/nvim-treesitter-context)
(WPlug :nvim-treesitter/playground)
(WPlug :saadparwaiz1/cmp_luasnip)
(WPlug :L3MON4D3/LuaSnip)
(WPlug :mickael-menu/zk-nvim)
(WPlug :arthurxavierx/vim-caser)
(WPlug "~/local_repos/ts-ql")
(vim.call "plug#end")
(vim.cmd "if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
PlugInstall --sync | autocmd VimEnter * so $MYVIMRC
endif
")
(vim.api.nvim_create_autocmd [:VimEnter]
{:callback (fn []
(fn named-term [term-idx term-name]
((. (require :harpoon.term)
:gotoTerminal) term-idx)
(vim.cmd (.. ":exe \":file "
term-name
"\" | :bfirst")))
(named-term 4 "term:ctl")
(named-term 5 "term:dev")
(named-term 7 "term:repl")
(named-term 6 "term:repl2"))})
(set vim.g.gruvbox_contrast_dark :soft)
(set vim.g.gruvbox_contrast_light :soft)
(set vim.opt.ignorecase true)
(set vim.opt.smartcase true)
(set vim.opt.incsearch true)
(set vim.opt.number true)
(set vim.opt.relativenumber true)
(set vim.opt.autoindent true)
(set vim.opt.smartindent true)
(set vim.opt.expandtab true)
(set vim.opt.exrc true)
(set vim.opt.tabstop 4)
(set vim.opt.softtabstop 4)
(set vim.opt.shiftwidth 4)
(set vim.opt.scrolloff 30)
(set vim.opt.signcolumn :yes)
(set vim.opt.colorcolumn :80)
(set vim.opt.background :dark)
(vim.api.nvim_create_user_command :Dark
(fn [opts]
(let [contrast (or (and (and opts.args
(> (string.len opts.args)
0))
opts.args)
vim.g.gruvbox_contrast_dark)]
(set vim.g.gruvbox_contrast_dark contrast)
(set vim.opt.background :dark)))
{:nargs "?"})
(vim.api.nvim_create_user_command :Light
(fn [opts]
(let [contrast (or (and (and opts.args
(> (string.len opts.args)
0))
opts.args)
vim.g.gruvbox_contrast_light)]
(set vim.g.gruvbox_contrast_light
contrast)
(set vim.opt.background :light)))
{:nargs "?"})
(set vim.opt.lazyredraw true)
(set vim.opt.termguicolors true)
(set vim.opt.cursorline true)
(set vim.opt.swapfile false)
(set vim.opt.backup false)
(set vim.opt.undodir (.. (vim.fn.stdpath :state) :/.vim/undodir))
(set vim.opt.undofile true)
(set vim.opt.completeopt "menuone,noselect")
(set vim.opt.updatetime 50)
(set vim.g.mapleader " ")
(set vim.g.maplocalleader ",")
(vim.keymap.set [:n :v] :<Space> :<Nop> {:silent true})
(vim.keymap.set :t :<Esc> "<C-\\><C-n>)")
(vim.keymap.set [:n :i :v] :<c-l> :<Cmd>mode<Cr> {:desc ""})
(vim.keymap.set :n "[d" vim.diagnostic.goto_prev)
(vim.keymap.set :n "]d" vim.diagnostic.goto_next)
(vim.keymap.set :n :<leader>e vim.diagnostic.open_float)
(vim.keymap.set :n :<leader>q "<cmd>TroubleToggle loclist<cr>")
(vim.keymap.set :n :<leader>wq "<cmd>TroubleToggle workspace_diagnostics<cr>")
(vim.keymap.set :n :<leader>gg :<cmd>GuessIndent<cr>)
(vim.cmd "colorscheme gruvbox\n")
((. (require :hlargs) :setup))
((. (require :nvim-web-devicons) :setup))
((. (require :trouble) :setup))
((. (require :todo-comments) :setup))
(fn remap [mode key-cmd binded-fn opts]
(set-forcibly! opts (or opts {:remap true}))
(vim.keymap.set mode key-cmd binded-fn opts))
((. (require :Comment) :setup))
(set vim.opt.list true)
(vim.opt.listchars:append "space:⋅")
(vim.opt.listchars:append "eol:↴")
((. (require :indent_blankline) :setup) {:show_end_of_line true
:space_char_blankline " "})
(vim.api.nvim_create_user_command :HalfSpaces
(fn [opts]
(vim.api.nvim_command "set ts=2 sts=2 noet")
(vim.api.nvim_command :retab!)
(vim.api.nvim_command "set ts=1 sts=1 et")
(vim.api.nvim_command :retab)
(vim.api.nvim_command :GuessIndent))
{:nargs 0})
(vim.api.nvim_create_user_command :DoubleSpaces
(fn [opts]
(vim.api.nvim_command "set ts=2 sts=2 noet")
(vim.api.nvim_command :retab!)
(vim.api.nvim_command "set ts=4 sts=4 et")
(vim.api.nvim_command :retab)
(vim.api.nvim_command :GuessIndent))
{:nargs 0})
(local fb-actions (. (. (. (require :telescope) :extensions) :file_browser)
:actions))
((. (require :telescope) :setup) {:defaults {:mappings {:i {:<C-d> false
:<C-u> false}}}
:extensions {:file_browser {:hiject_netrw true
:mappings {:i {}
:n {:c fb-actions.create
:d fb-actions.remove
:e fb-actions.goto_home_dir
:f fb-actions.toggle_browser
:g fb-actions.goto_parent_dir
:h fb-actions.toggle_hidden
:m fb-actions.move
:o fb-actions.open
:r fb-actions.rename
:s fb-actions.toggle_all
:t fb-actions.change_cwd
:w fb-actions.goto_cwd
:y fb-actions.copy}}
:theme (. ((. (require :telescope.themes)
:get_ivy))
:theme)}
:fzf {:case_mode :smart_case
:fuzzy true
:override_file_sorter true
:override_generic_sorter true}}})
(pcall (. (require :telescope) :load_extension) :fzf)
(pcall (. (require :telescope) :load_extension) :file_browser)
(remap :n :<C-p> :<cmd>Telescope<cr> {:desc "Open Telescope general search"})
(remap :n :<leader>fm (fn []
((. (. (. (require :telescope) :extensions)
:file_browser)
:file_browser) {}))
{:desc "[F]ile [M]utation"})
(remap :n :<leader>ff
(fn []
((. (require :telescope.builtin) :find_files) {:follow false
:hidden false
:no_ignore false}))
{:desc "[F]ind [F]ile"})
(remap :n :<leader>fa
(fn []
((. (require :telescope.builtin) :find_files) {:follow true
:hidden true
:no_ignore true}))
{:desc "[F]ind [A]ll files"})
(remap :n :<leader>fg
(fn []
((. (require :telescope.builtin) :live_grep)))
{:desc "[F]ind by [G]rep"})
(remap :n :<leader>fug
(fn []
((. (require :telescope.builtin) :live_grep) {:glob_pattern "**/*"}))
{:desc "[F]ind by [u]nrestricted [G]rep"})
(remap :n :<leader>fb
(fn []
((. (require :telescope.builtin) :buffers)))
{:desc "[F]ind existing [B]uffers"})
(remap :n :<leader>fh
(fn []
((. (require :telescope.builtin) :help_tags)))
{:desc "[F]ind [H]elp"})
(remap :n :<leader>fd
(fn []
((. (require :telescope.builtin) :diagnostics)))
{:desc "[F]ind [D]iagnostics"})
(remap :n :<leader>zf
(fn []
((. (require :zk) :edit) {} {:multi_select false}))
{:desc "[Z]ettelkasten [F]iles"})
(remap :n :<leader>zg (fn [] (vim.cmd ":ZkGrep"))
{:desc "[Z]ettelkasten [G]rep"})
(for [i 1 9]
(vim.api.nvim_set_keymap :n (.. :<C-t> i) (.. ":tabn " i :<CR>)
{:noremap true :silent true}))
(set vim.o.showtabline 1)
(set vim.o.tabline "%!v:lua.my_tabline()")
(fn _G.my_tabline []
(var s "")
(for [i 1 (vim.fn.tabpagenr "$")]
(if (= i (vim.fn.tabpagenr)) (set s (.. s "%" i "T%#TabLineSel#"))
(set s (.. s "%" i "T%#TabLine#")))
(local tab (. (vim.fn.gettabinfo i) 1))
(local tabbuf tab.variables.buffers)
(var bufname :<unknown>)
(when tabbuf
(set bufname (. (. tabbuf tab.curwin) :name)))
(set s (.. s " " i " " (vim.fn.fnamemodify bufname ":t")))
(when (not= i (vim.fn.tabpagenr "$"))
(set s (.. s "%#TabLine#|%#TabLine#"))))
(.. s "%T%#TabLineFill#%="))
(vim.api.nvim_set_keymap :n :<C-t>x
":tabdo if tabpagenr() > 1 | tabclose | endif<CR>"
{:noremap true :silent true})
(require :treesitter-context)
((. (require :nvim-treesitter.configs) :setup) {:autotag {:enable true}
:highlight {:enable true
:enable_vim_regex_highlighting true}
:incremental_selection {:enable true
:keymaps {:init_selection :<C-space>
:node_decremental :<C-backspace>
:node_incremental :<C-space>
:pscope_incremental :<C-S>}}
:indent {:enable false}
:playground {:disable {}
:enable true}
:textobjects {:select {:enable true
:keymaps {:ac "@class.outer"
:af "@function.outer"
:ic "@class.inner"
:if "@function.inner"}
:lookahead true}}
:yati {:default_fallback :auto
:default_lazy true
:disable [:nix]
:enable true}})
((. (require :nvim-autopairs) :setup) {:check_ts true})
(local parser-config
((. (require :nvim-treesitter.parsers) :get_parser_configs)))
(set parser-config.tsx.filetype_to_parsername [:javascript :typescript.tsx])
(set parser-config.astro.filetype_to_parsername
[:javascript :typescript.tsx :astro])
((. (require :guess-indent) :setup) {:auto_cmd true
:filetype_exclude [:netrw :tutor]})
(remap :n :<leader>m
(fn []
((. (require :harpoon.mark) :add_file)))
{:desc "[H]arpoon [M]ark"})
(fn harpoon-nav [key nav-file-index lead-keybind]
(set-forcibly! lead-keybind (or lead-keybind :<leader>h))
(assert (= (type key) :string) "expect key to be string(keybind)")
(assert (and (= (type nav-file-index) :number) (>= nav-file-index 1))
"expect 1-indexed number for file index")
(remap :n (.. lead-keybind key)
(fn []
((. (require :harpoon.ui) :nav_file) nav-file-index))
{:desc (.. "[H]arpoon navigate " (tostring nav-file-index))}))
(harpoon-nav :f 1)
(harpoon-nav :j 2)
(harpoon-nav :d 3)
(harpoon-nav :k 4)
(remap :n :<leader>hh
(fn []
((. (require :harpoon.ui) :toggle_quick_menu))))
(for [i 1 10]
(harpoon-nav (tostring (% i 10)) i)
(remap :n (.. :<leader>t (tostring (% i 10)))
(fn []
((. (require :harpoon.term) :gotoTerminal) i))))
((. (require :neogit) :setup) {})
(remap :n :<leader>gs (fn []
((. (require :neogit) :open) {}))
{:desc "[G]it [S]tatus"})
((. (require :inlay-hints) :setup) {:eol {:right_align false}
:only_current_line false})
(fn on-attach [client bufnr]
(fn nmap [keys func desc]
(when desc (set-forcibly! desc (.. "LSP: " desc)))
(vim.keymap.set :n keys func {:buffer bufnr : desc :noremap true}))
(nmap :<leader>rn vim.lsp.buf.rename "[R]e[n]ame")
(nmap :<leader>ca vim.lsp.buf.code_action "[C]ode [A]ction")
(vim.api.nvim_buf_set_option bufnr :omnifunc "v:lua.vim.lsp.omnifunc")
(nmap :<leader>df (fn [] (vim.lsp.buf.format {:async true}))
"[D]ocument [F]ormat")
(nmap :gd vim.lsp.buf.definition "[G]oto [D]efinition")
(nmap :gi vim.lsp.buf.implementation "[G]oto [I]mplementation")
(nmap :gr (. (require :telescope.builtin) :lsp_references))
(nmap :<leader>ds (. (require :telescope.builtin) :lsp_document_symbols)
"[D]ocument [S]ymbols")
(nmap :<leader>ws (. (require :telescope.builtin)
:lsp_dynamic_workspace_symbols)
"[W]orkspace [S]ymbols")
(nmap :K vim.lsp.buf.hover "Hover Documentation")
(nmap :<C-k> vim.lsp.buf.signature_help "Signature Documentation")
(nmap :gD vim.lsp.buf.declaration "[G]oto [D]eclaration")
(nmap :gtd vim.lsp.buf.type_definition "[G]oto [T]ype [D]efinition")
(nmap :<leader>D vim.lsp.buf.type_definition "Type [D]efinition")
(nmap :<leader>wa vim.lsp.buf.add_workspace_folder "[W]orkspace [A]dd Folder")
(nmap :<leader>wr vim.lsp.buf.remove_workspace_folder
"[W]orkspace [R]emove Folder")
(nmap :<leader>wl
(fn []
(print (vim.inspect (vim.lsp.buf.list_workspace_folders))))
"[W]orkspace [L]ist Folders")
((. (require :inlay-hints) :on_attach) client bufnr))
(local cmp (require :cmp))
(local luasnip (require :luasnip))
(local lspkind (require :lspkind))
(local source-mapping {:buffer "[Buffer]"
:nvim_lsp "[LSP]"
:nvim_lua "[Lua]"
:path "[Path]"})
(cmp.event:on :confirm_done ((. (require :nvim-autopairs.completion.cmp)
:on_confirm_done)))
(cmp.setup {:formatting {:format (fn [entry vim-item]
(set vim-item.kind
(lspkind.symbolic vim-item.kind
{:mode :symbol}))
(set vim-item.menu
(. source-mapping entry.source_name))
(local maxwidth 80)
(set vim-item.abbr
(string.sub vim-item.abbr 1 maxwidth))
vim-item)}
:mapping (cmp.mapping.preset.insert {:<C-d> (cmp.mapping.scroll_docs 4)
:<C-space> (cmp.mapping.complete)
:<C-u> (cmp.mapping.scroll_docs (- 4))
:<CR> (cmp.mapping.confirm {:behavior cmp.ConfirmBehavior.Replace
:select true})
:<S-Tab> (cmp.mapping (fn [fallback]
(if (cmp.visible)
(cmp.select_prev_item)
(luasnip.jumpable (- 1))
(luasnip.jump (- 1))
(fallback)))
[:i :s])
:<Tab> (cmp.mapping (fn [fallback]
(if (cmp.visible)
(cmp.select_next_item)
(luasnip.expand_or_jumpable)
(luasnip.expand_or_jump)
(fallback)))
[:i :s])})
:snippet {:expand (fn [args] (luasnip.lsp_expand args.body))}
:sources (cmp.config.sources [{:name :nvim_lsp}
{:name :luasnip}
{:name :buffer}
{:name :path}])})
(local capabilities ((. (require :cmp_nvim_lsp) :default_capabilities)))
(local servers [: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])
((. (require :mason) :setup) {:PATH :append
:ui {:check_outdated_packages_on_open true
:icons {:package_installed "✓"
:package_pending "➜"
:package_uninstalled "✗"}}})
((. (require :mason-lspconfig) :setup) {:automatic_installation false})
(local inlay-hint-tsjs
{:includeInlayEnumMemberValueHints true
:includeInlayFunctionLikeReturnTypeHints true
:includeInlayFunctionParameterTypeHints true
:includeInlayParameterNameHints :all
:includeInlayPropertyDeclarationTypeHints true
:includeInlayVariableTypeHints true
:inlcudeInlayParameterNameHintsWhenArgumentMatchesName false})
((. (require :mason-lspconfig) :setup_handlers) {1 (fn [server-name]
((. (. (require :lspconfig)
server-name)
:setup) {: capabilities
:on_attach on-attach}))
:denols (fn []
((. (. (require :lspconfig)
:denols)
:setup) {: capabilities
:on_attach on-attach
:root_dir ((. (require :lspconfig.util)
:root_pattern) :deno.json
:deno.jsonc)}))
:lua_ls (fn []
((. (. (require :lspconfig)
:lua_ls)
:setup) {: capabilities
:on_attach on-attach
:settings {:Lua {:diagnostics {:globals [:vim]}
:format {:defaultConfig {:indent_size 4
:indent_style :space}
:enable true}
:hint {:enable true}
:runtime {:path (vim.split package.path
";")
:version :LuaJIT}
:telemetry {:enable false}
:workspace {:library (vim.api.nvim_get_runtime_file ""
true)}}}}))
:pyright (fn []
((. (. (require :lspconfig)
:pyright)
:setup) {: capabilities
:on_attach on-attach
:settings {:pyright {:disableLanguageServices false
:disableOrganizeImports false}
:python {:analysis {:autoImportCompletions true
:autoSearchPaths true
:diagnosticMode :openFilesOnly
:extraPaths {}
:logLevel :Information
:pythonPath :python
:stubPath :typings
:typeCheckingMode :basic
:typeshedPaths {}
:useLibraryCodeForTypes false
:venvPath ""}
:linting {:mypyEnabled true}}}}))
:tsserver (fn []
((. (. (require :lspconfig)
:tsserver)
:setup) {: capabilities
:on_attach on-attach
:root_dir ((. (require :lspconfig.util)
:root_pattern) :package.json)
:settings {:javascript inlay-hint-tsjs
:typescript inlay-hint-tsjs}}))
:yamlls (fn []
((. (. (require :lspconfig)
:yamlls)
:setup) {: capabilities
:on_attach on-attach
:settings {:yaml {:keyOrdering false}}}))})
((. (require :rust-tools) :setup) {:dap {:adapter {:command :lldb-vscode
:name :rt_lldb
:type :executable}}
:server {: capabilities
:cmd [:rust-analyzer]
:on_attach (fn [client bufnr]
(fn nmap [keys
func
desc]
(when desc
(set-forcibly! desc
(.. "LSP: "
desc)))
(vim.keymap.set :n
keys
func
{:buffer bufnr
: desc
:noremap true}))
(on-attach client
bufnr)
(nmap :K
(. (. (require :rust-tools)
:hover_actions)
:hover_actions)
"Hover Documentation"))
:settings {:rust-analyzer {:cargo {:loadOutDirsFromCheck true}
:checkOnSave {:command :clippy
:extraArgs [:--all
"--"
:-W
"clippy::all"]}
:procMacro {:enable true}
:rustfmt {:extraArgs [:+nightly]}}}
:standalone true}
:tools {:crate_graph {:backend :x11
:enabled_graphviz_backends [:bmp
:cgimage
:canon
:dot
:gv
:xdot
:xdot1.2
:xdot1.4
:eps
:exr
:fig
:gd
:gd2
:gif
:gtk
:ico
:cmap
:ismap
:imap
:cmapx
:imap_np
:cmapx_np
:jpg
:jpeg
:jpe
:jp2
:json
:json0
:dot_json
:xdot_json
:pdf
:pic
:pct
:pict
:plain
:plain-ext
:png
:pov
:ps
:ps2
:psd
:sgi
:svg
:svgz
:tga
:tiff
:tif
:tk
:vml
:vmlz
:wbmp
:webp
:xlib
:x11]
:full true
:output nil}
:executor (. (require :rust-tools/executors)
:termopen)
:hover_actions {:auto_focus false
:border [["╭"
:FloatBorder]
["─"
:FloatBorder]
["╮"
:FloatBorder]
["│"
:FloatBorder]
["╯"
:FloatBorder]
["─"
:FloatBorder]
["╰"
:FloatBorder]
["│"
:FloatBorder]]}
:inlay_hints {:auto false
:highlight :NonText
:max_len_align false
:max_len_align_padding 1
:only_current_line true
:other_hints_prefix "=> "
:parameter_hints_prefix "<- "
:right_align false
:right_align_padding 7
:show_parameter_hints true}
:on_initialized (fn []
((. (require :inlay-hints)
:set_all)))
:reload_workspace_from_cargo_toml true}})
((. (require :zk) :setup) {:lsp {:auto_attach {:enable true
:filetypes [:markdown]}
:config {:cmd [:zk :lsp]
:name :zk
:on_attach on-attach}}
:picker :telescope})
((. (require :zk.commands) :add) :ZkOrphans
(fn [options]
(set-forcibly! options
(vim.tbl_extend :force
{:orphan true}
(or options
{})))
((. (require :zk) :edit) options
{:title "Zk Orphans (unlinked notes)"})))
((. (require :zk.commands) :add) :ZkGrep
(fn [match-ctor]
(var grep-str match-ctor)
(var ___match___ nil)
(if (or (= match-ctor nil) (= match-ctor ""))
(do
(vim.fn.inputsave)
(set grep-str
(vim.fn.input "Grep string: >"))
(vim.fn.inputrestore)
(set ___match___ {:match grep-str}))
(= (type match-ctor) :string)
(set ___match___ {:match grep-str}))
((. (require :zk) :edit) ___match___
{:mutli_select false
:title (.. "Grep: '"
grep-str
"'")})))
((. (require :gitsigns) :setup) {:signs {:add {:text "+"}
:change {:text "~"}
:changedelete {:text "~"}
:delete {:text "_"}
:topdelete {:text "‾"}}})
((. (require :lualine) :setup) {:inactive_sections {:lualine_a {}
:lualine_b {}
:lualine_c [{1 :filename
:file_status true
:path 1}]
:lualine_x [:location]
:lualine_y {}
:lualine_z {}}
:options {:icons_enabled true}
:sections {:lualine_a [:mode]
:lualine_b [:branch
:diff
:diagnostics]
:lualine_c [{1 :filename
:file_status true
:newfile_status false
:path 1
:symbols {:modified "[+]"
:newfile "[New]"
:readonly "[-]"
:unnamed "[Unnamed]"}}]
:lualine_x [:encoding
:fileformat
:filetype]
:lualine_y [:progress]
:lualine_z [:location]}})
((. (require :nvim-surround) :setup) {})
((. (require :tsql) :setup))
((. (require :fidget) :setup) {:align {:bottom true :right true}
:debug {:logging false :strict false}
:fmt {:fidget (fn [fidget-name spinner]
(string.format "%s %s" spinner
fidget-name))
:leftpad true
:max_width 0
:stack_upwards true
:task (fn [task-name message percentage]
(string.format "%s%s [%s]" message
(or (and percentage
(string.format " (%s%%)"
percentage))
"")
task-name))}
:sources {:* {:ignore false}}
:text {:commenced :Started
:completed :Completed
:done "✔"
:spinner :moon}
:timer {:fidget_decay 2000
:spinner_rate 125
:task_decay 1000}
:window {:blend 100
:border :none
:relative :editor
:zindex nil}})

View File

@ -8,6 +8,7 @@
-- - zk @ https://github.com/mickael-menu/zk -- - zk @ https://github.com/mickael-menu/zk
-- - prettierd @ npm install -g @fsouza/prettierd -- - prettierd @ npm install -g @fsouza/prettierd
-- Auto-installs vim-plug
vim.cmd([[ vim.cmd([[
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim' let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
let plug_path = data_dir . '/autoload/plug.vim' let plug_path = data_dir . '/autoload/plug.vim'
@ -20,83 +21,102 @@ endif
-- vim-plug -- vim-plug
local Plug = vim.fn['plug#'] local Plug = vim.fn['plug#']
-- prepare a list of installed plugins from rtp
local installed_plugins = {}
-- NOTE: nvim_list_runtime_paths will expand wildcard paths for us.
for _, path in ipairs(vim.api.nvim_list_runtime_paths()) do
local last_folder_start = path:find("/[^/]*$")
if last_folder_start then
local plugin_name = path:sub(last_folder_start + 1)
installed_plugins[plugin_name] = true
end
end
-- Do Plug if plugin not yet linked in `rtp`. This takes care of Nix-compatibility
local function WPlug(plugin_path, ...)
local plugin_name = string.lower(plugin_path:match("/([^/]+)$"))
if not installed_plugins[plugin_name] then
Plug(plugin_path, ...)
end
end
vim.call('plug#begin') vim.call('plug#begin')
-- libs and dependencies -- libs and dependencies
-- Plug('nvim-lua/plenary.nvim') -- The base of all plugins -- Plug('nvim-lua/plenary.nvim') -- The base of all plugins
-- plugins -- plugins
-- Plug('tjdevries/nlua.nvim') -- adds symbols of vim stuffs in init.lua WPlug('tjdevries/nlua.nvim') -- adds symbols of vim stuffs in init.lua
-- Plug('nvim-treesitter/nvim-treesitter') -- language parser engine for highlighting WPlug('nvim-treesitter/nvim-treesitter') -- language parser engine for highlighting
-- Plug('nvim-treesitter/nvim-treesitter-textobjects') -- more text objects WPlug('nvim-treesitter/nvim-treesitter-textobjects') -- more text objects
-- Plug('nvim-telescope/telescope.nvim', { branch = '0.1.x' }) -- file browser WPlug('nvim-telescope/telescope.nvim', { branch = '0.1.x' }) -- file browser
-- TODO: this might need to be taken extra care in our Nix config -- 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 -- What this WPlug declaration means is this repo needs to be built on our running environment
-- ----- -- -----
-- What to do: -- What to do:
-- - Run `make` at anytime before Nix is done on this repository -- - Run `make` at anytime before Nix is done on this repository
-- - Might mean that we fetch this repository, run make, and copy to destination folder -- - Might mean that we fetch this repository, run make, and copy to destination folder
-- - Make sure that if we run `make` at first Plug run, that `make` is idempotent -- - Make sure that if we run `make` at first WPlug run, that `make` is idempotent
-- OR -- OR
-- Make sure that Plug does not run `make` and use the output it needs -- Make sure that WPlug does not run `make` and use the output it needs
-- Plug('nvim-telescope/telescope-fzf-native.nvim', WPlug('nvim-telescope/telescope-fzf-native.nvim',
-- { ['do'] = 'make >> /tmp/log 2>&1' }) { ['do'] = 'make >> /tmp/log 2>&1' })
-- Plug('nvim-telescope/telescope-file-browser.nvim') WPlug('nvim-telescope/telescope-file-browser.nvim')
-- cmp: auto-complete/suggestions -- cmp: auto-complete/suggestions
-- Plug('neovim/nvim-lspconfig') -- built-in LSP configurations WPlug('neovim/nvim-lspconfig') -- built-in LSP configurations
-- Plug('hrsh7th/cmp-nvim-lsp') WPlug('hrsh7th/cmp-nvim-lsp')
-- Plug('hrsh7th/cmp-path') WPlug('hrsh7th/cmp-path')
-- Plug('hrsh7th/cmp-buffer') WPlug('hrsh7th/cmp-buffer') -- Recommends words within the buffer
-- Plug('hrsh7th/cmp-cmdline') WPlug('hrsh7th/cmp-cmdline')
-- Plug('hrsh7th/nvim-cmp') WPlug('hrsh7th/nvim-cmp')
-- Plug('onsails/lspkind-nvim') WPlug('onsails/lspkind-nvim')
Plug('yioneko/nvim-yati', { tag = '*' }) -- copium: fix Python indent auto-correct from smart-indent WPlug('yioneko/nvim-yati', { tag = '*' }) -- copium: fix Python indent auto-correct from smart-indent
Plug('nathanalderson/yang.vim') WPlug('nathanalderson/yang.vim')
-- Plug('tzachar/cmp-tabnine', { ['do'] = './install.sh' }) -- WPlug('tzachar/cmp-tabnine', { ['do'] = './install.sh' })
-- DevExp -- DevExp
-- Plug('windwp/nvim-autopairs') -- matches pairs like [] (),... WPlug('windwp/nvim-autopairs') -- matches pairs like [] (),...
-- Plug('windwp/nvim-ts-autotag') -- matches tags <body>hello</body> WPlug('windwp/nvim-ts-autotag') -- matches tags <body>hello</body>
-- Plug('NMAC427/guess-indent.nvim') -- guesses the indentation of an opened buffer WPlug('NMAC427/guess-indent.nvim') -- guesses the indentation of an opened buffer
-- Plug('j-hui/fidget.nvim') -- Progress bar for LSP WPlug('j-hui/fidget.nvim') -- Progress bar for LSP
Plug('numToStr/Comment.nvim') -- "gc" to comment visual regions/lines WPlug('numToStr/Comment.nvim') -- "gc" to comment visual regions/lines
Plug('lewis6991/gitsigns.nvim') -- add git info to sign columns WPlug('lewis6991/gitsigns.nvim') -- add git info to sign columns
Plug('tpope/vim-fugitive') -- git commands in nvim WPlug('tpope/vim-fugitive') -- git commands in nvim
Plug('williamboman/mason.nvim') -- LSP, debuggers,... package manager WPlug('williamboman/mason.nvim') -- LSP, debuggers,... package manager
Plug('williamboman/mason-lspconfig.nvim') -- lsp config for mason WPlug('williamboman/mason-lspconfig.nvim') -- lsp config for mason
-- Plug('ThePrimeagen/harpoon') -- 1-click through marked files per project WPlug('ThePrimeagen/harpoon') -- 1-click through marked files per project
Plug('TimUntersberger/neogit') -- Easy-to-see git status WPlug('TimUntersberger/neogit') -- Easy-to-see git status
Plug('folke/trouble.nvim') -- File-grouped workspace diagnostics WPlug('folke/trouble.nvim') -- File-grouped workspace diagnostics
Plug('tpope/vim-dispatch') -- Allows quick build/compile/test vim commands WPlug('tpope/vim-dispatch') -- Allows quick build/compile/test vim commands
Plug('clojure-vim/vim-jack-in') -- Clojure: ":Boot", ":Clj", ":Lein" WPlug('clojure-vim/vim-jack-in') -- Clojure: ":Boot", ":Clj", ":Lein"
Plug('radenling/vim-dispatch-neovim') -- Add support for neovim's terminal emulator WPlug('radenling/vim-dispatch-neovim') -- Add support for neovim's terminal emulator
-- Plug('Olical/conjure') -- REPL on the source for Clojure (and other LISPs) -- WPlug('Olical/conjure') -- REPL on the source for Clojure (and other LISPs)
Plug('gennaro-tedesco/nvim-jqx') -- JSON formatter (use :Jqx*) WPlug('gennaro-tedesco/nvim-jqx') -- JSON formatter (use :Jqx*)
Plug('kylechui/nvim-surround') -- surrounds with tags/parenthesis WPlug('kylechui/nvim-surround') -- surrounds with tags/parenthesis
Plug('simrat39/rust-tools.nvim') -- config rust-analyzer and nvim integration WPlug('simrat39/rust-tools.nvim') -- config rust-analyzer and nvim integration
-- UI & colorscheme -- UI & colorscheme
Plug('simrat39/inlay-hints.nvim') -- type-hints with pseudo-virtual texts WPlug('simrat39/inlay-hints.nvim') -- type-hints with pseudo-virtual texts
-- Plug('gruvbox-community/gruvbox') -- theme provider WPlug('gruvbox-community/gruvbox') -- theme provider
Plug('nvim-lualine/lualine.nvim') -- fancy status line WPlug('nvim-lualine/lualine.nvim') -- fancy status line
Plug('lukas-reineke/indent-blankline.nvim') -- identation lines on blank lines WPlug('lukas-reineke/indent-blankline.nvim') -- identation lines on blank lines
Plug('kyazdani42/nvim-web-devicons') -- icons for folder and filetypes WPlug('kyazdani42/nvim-web-devicons') -- icons for folder and filetypes
Plug('m-demare/hlargs.nvim') -- highlights arguments; great for func prog WPlug('m-demare/hlargs.nvim') -- highlights arguments; great for func prog
Plug('folke/todo-comments.nvim') -- Highlights TODO WPlug('folke/todo-comments.nvim') -- Highlights TODO
-- other utilities -- other utilities
Plug('nvim-treesitter/nvim-treesitter-context') -- Top one-liner context of func/class scope WPlug('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 WPlug('nvim-treesitter/playground') -- Sees Treesitter AST - less hair pulling, more PRs
Plug('saadparwaiz1/cmp_luasnip') -- snippet engine WPlug('saadparwaiz1/cmp_luasnip') -- snippet engine
-- Plug('L3MON4D3/LuaSnip') -- snippet engine WPlug('L3MON4D3/LuaSnip') -- snippet engine
-- Plug('mickael-menu/zk-nvim') -- Zettelkasten WPlug('mickael-menu/zk-nvim') -- Zettelkasten
-- Switch cases: -- Switch cases:
-- `gsp` -> PascalCase (classes), `gsc` -> camelCase (Java), `gs_` -> snake_case (C/C++/Rust) -- `gsp` -> PascalCase (classes), `gsc` -> camelCase (Java), `gs_` -> snake_case (C/C++/Rust)
-- `gsu` -> UPPER_CASE (CONSTs), `gsk` -> kebab-case (Clojure), `gsK` -> Title-Kebab-Case -- `gsu` -> UPPER_CASE (CONSTs), `gsk` -> kebab-case (Clojure), `gsK` -> Title-Kebab-Case
-- `gs.` -> dot.case (R) -- `gs.` -> dot.case (R)
Plug('arthurxavierx/vim-caser') -- switch cases WPlug('arthurxavierx/vim-caser') -- switch cases
Plug('~/local_repos/ts-ql') -- workspace code intelligence WPlug('~/local_repos/ts-ql') -- workspace code intelligence
--------- ---------
vim.call('plug#end') vim.call('plug#end')
@ -624,11 +644,34 @@ cmp.setup {
sources = cmp.config.sources { sources = cmp.config.sources {
{ name = 'nvim_lsp' }, { name = 'nvim_lsp' },
{ name = 'luasnip' }, { name = 'luasnip' },
{ name = 'buffer' }, {
name = 'buffer',
option = {
-- default is only in the current buffer. This grabs recommendations
-- from all visible buffers
get_bufnrs = function()
local bufs = {}
for _, win in ipairs(vim.api.nvim_list_wins()) do
local buf = vim.api.nvim_win_get_buf(win)
local byte_size = vim.api.nvim_buf_get_offset(buf, vim.api.nvim_buf_line_count(buf))
if byte_size <= 1024 * 1024 then -- 1 MiB max
bufs[buf] = true
end
end
return vim.tbl_keys(bufs)
end,
}
},
{ name = 'path' }, { name = 'path' },
-- { name = "conjure" }, -- { name = "conjure" },
-- { name = 'cmp_tabnine' }, -- { name = 'cmp_tabnine' },
}, },
sorting = {
comparators = {
-- Optimize searches by recommending things that are closer to the current cursor
function(...) require('cmp-buffer'):compare_locality(...) end,
}
},
} }
-- nvim-cmp supports additional completion capabilities -- nvim-cmp supports additional completion capabilities
local capabilities = require('cmp_nvim_lsp').default_capabilities() local capabilities = require('cmp_nvim_lsp').default_capabilities()
@ -782,30 +825,6 @@ require('mason-lspconfig').setup_handlers({
}, },
} }
end, end,
-- ["rust_analyzer"] = function()
-- require('lspconfig').rust_analyzer.setup {
-- on_attach = on_attach,
-- capabilities = capabilities,
-- settings = {
-- checkOnSave = {
-- command = "clippy",
-- }
-- }
-- }
-- end,
-- ["astro"] = function()
-- print('configuring astro')
-- require('lspconfig').astro.setup {
-- on_attach = on_attach,
-- capabilities = capabilities,
-- init_options = {
-- configuration = {},
-- typescript = {
-- serverPath = data_dir
-- }
-- }
-- }
-- end
}) })
require("rust-tools").setup { require("rust-tools").setup {
tools = { tools = {

View File

@ -1,9 +1,8 @@
# TODO: vim-plug and Mason supports laziness. Probably worth it to explore # TODO: vim-plug and Mason supports laziness. Probably worth it to explore incremental dependencies based on the project
# incremental dependencies based on the project
# TODO: just install these things, then symlink to mason's bin directory # TODO: just install these things, then symlink to mason's bin directory
# #
# One thing to consider, though, /nix/store of `nix-shell` or `nix-develop` # One thing to consider, though, /nix/store of `nix-shell` or `nix-develop`
# might be different from `home-manager`'s # might be different from `home-manager`'s (~/.nix_profile/bin/jq)
{ pkgs, lib, config, proj_root, ... }: { pkgs, lib, config, proj_root, ... }:
let let
# NOTE: Add packages to nvim_pkgs instead, so that it's available at userspace # NOTE: Add packages to nvim_pkgs instead, so that it's available at userspace
@ -34,7 +33,6 @@ let
pkgs.go # doesn't work, Mason installs from runtime path pkgs.go # doesn't work, Mason installs from runtime path
# Language-specific stuffs # Language-specific stuffs
pkgs.sumneko-lua-language-server pkgs.sumneko-lua-language-server
# pkgs.python3Packages.python-lsp-server # pkgs.python3Packages.python-lsp-server
@ -78,21 +76,7 @@ in
vimAlias = true; vimAlias = true;
withPython3 = true; withPython3 = true;
withNodeJs = true; withNodeJs = true;
# Attempt 4: Correct way to make neovim aware of packages
# homeConfigurations.config.programs.neovim takes UNWRAPPED neovim
# and wraps it.
# Ideally, we build our own neovim and add that to config.home.packages
# to share it with nixOS. But we don't really need to share
extraPackages = nvim_pkgs; extraPackages = nvim_pkgs;
# only for here for archive-documentation
# extraPython3Packages = (pypkgs: [
# # pypkgs.python-lsp-server
# pypkgs.ujson
# ]);
# I use vim-plug, so I probably don't require packaging
# extraConfig actually writes to init-home-manager.vim (not lua)
# 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"); extraLuaConfig = (builtins.readFile "${proj_root.config.path}//neovim/init.lua");
plugins = (let inherit (pkgs.vimPlugins) plugins = (let inherit (pkgs.vimPlugins)
plenary-nvim plenary-nvim
@ -125,6 +109,27 @@ in
zk-nvim zk-nvim
luasnip luasnip
fidget-nvim fidget-nvim
rust-tools-nvim
cmp_luasnip
gitsigns-nvim
indent-blankline-nvim
lualine-nvim
mason-lspconfig-nvim
mason-nvim
neogit
nlua-nvim
nvim-jqx
nvim-surround
nvim-web-devicons
playground
todo-comments-nvim
trouble-nvim
vim-dispatch
vim-dispatch-neovim
vim-fugitive
vim-jack-in
; in [ ; in [
plenary-nvim plenary-nvim
nvim-treesitter.withAllGrammars nvim-treesitter.withAllGrammars
@ -149,6 +154,26 @@ in
luasnip luasnip
nvim-treesitter-context nvim-treesitter-context
fidget-nvim fidget-nvim
rust-tools-nvim
cmp_luasnip
gitsigns-nvim
indent-blankline-nvim
lualine-nvim
mason-lspconfig-nvim
mason-nvim
neogit
nlua-nvim
nvim-jqx
nvim-surround
nvim-web-devicons
playground
todo-comments-nvim
trouble-nvim
vim-dispatch
vim-dispatch-neovim
vim-fugitive
vim-jack-in
]); ]);
}; };
# home.packages = nvim_pkgs; # home.packages = nvim_pkgs;

View File

@ -17,7 +17,7 @@ in
config.programs.ssh = { config.programs.ssh = {
inherit (cfg) enable; inherit (cfg) enable;
forwardAgent = true; forwardAgent = true;
extraConfig = builtins.readFile "${proj_root.config.path}/ssh/config"; includes = ["${proj_root.config.path}/ssh/config"];
}; };
} }

View File

@ -818,11 +818,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1686142265, "lastModified": 1686562199,
"narHash": "sha256-IP0xPa0VYqxCzpqZsg3iYGXarUF+4r2zpkhwdHy9WsM=", "narHash": "sha256-FG6kCtVjCh0dHnV4AsVfhfSyPhjnSVXucwqCdTpMASE=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "39c7d0a97a77d3f31953941767a0822c94dc01f5", "rev": "b0cdae4e9baa188d69ba84aa1b7406b7bebe37f6",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -953,11 +953,11 @@
"topiary": "topiary" "topiary": "topiary"
}, },
"locked": { "locked": {
"lastModified": 1686147433, "lastModified": 1686315162,
"narHash": "sha256-KqDqUGNfXcOwh6fkHMbH4a2W6k/W7S7wC/mxstlORwo=", "narHash": "sha256-KZZRTXSpxJDDGVbEdyTR/4Mu2COSMtrim+5iL7qwDTw=",
"owner": "tweag", "owner": "tweag",
"repo": "nickel", "repo": "nickel",
"rev": "dc6804acd123257460eef60d615da2eb0a8aca78", "rev": "9fed1326c9306d7c339884584702ce570764beaf",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -1197,11 +1197,11 @@
}, },
"nixpkgs_12": { "nixpkgs_12": {
"locked": { "locked": {
"lastModified": 1686020360, "lastModified": 1686501370,
"narHash": "sha256-Wee7lIlZ6DIZHHLiNxU5KdYZQl0iprENXa/czzI6Cj4=", "narHash": "sha256-G0WuM9fqTPRc2URKP9Lgi5nhZMqsfHGrdEbrLvAPJcg=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "4729ffac6fd12e26e5a8de002781ffc49b0e94b7", "rev": "75a5ebf473cd60148ba9aec0d219f72e5cf52519",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -1768,11 +1768,11 @@
"nixpkgs": "nixpkgs_13" "nixpkgs": "nixpkgs_13"
}, },
"locked": { "locked": {
"lastModified": 1686105195, "lastModified": 1686537156,
"narHash": "sha256-tBTKW+oqfT86Mvq/nm8Tkk3pzhJFXJWXJrj71cTF7lE=", "narHash": "sha256-mJD80brS6h6P4jzwdKID0S9RvfyiruxgJbXvPPIDqF0=",
"owner": "oxalica", "owner": "oxalica",
"repo": "rust-overlay", "repo": "rust-overlay",
"rev": "1279a72003f5e4b08c8eca1101d8f57452a539f9", "rev": "e75da5cfc7da874401decaa88f4ccb3b4d64d20d",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@ -80,11 +80,10 @@
nerd_font_module = { config, pkgs, ... }: { nerd_font_module = { config, pkgs, ... }: {
fonts.fontconfig.enable = true; fonts.fontconfig.enable = true;
home.packages = [ home.packages = [
(pkgs.nerdfonts.override { fonts = [ "DroidSansMono" ]; }) # list of fonts are available at https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/data/fonts/nerdfonts/shas.nix
(pkgs.nerdfonts.override { fonts = [ "Hack" ]; })
]; ];
# For some reasons, Windows es in the font name as DroidSansMono NF base.alacritty.font.family = "Hack Nerd Font Mono";
# so we need to override this
base.alacritty.font.family = "DroidSansMono Nerd Font";
}; };
in in
{ {
@ -184,14 +183,14 @@
{ {
base.private_chromium.enable = false; base.private_chromium.enable = false;
} }
nerd_font_module
{ {
base.graphics.enable = false; base.graphics.enable = false;
# don't want to deal with GL stuffs on mac yet :/ # don't want to deal with GL stuffs on mac yet :/
base.graphics.useNixGL.defaultPackage = null; base.graphics.useNixGL.defaultPackage = null;
# FIXME: this actually does not exist # FIXME: this actually does not exist
base.keepass.path = "/Users/htran/keepass.kdbx"; # base.keepass.path = "/Users/htran/keepass.kdbx";
base.alacritty.font.size = 11.0; base.alacritty.font.size = 11.0;
base.alacritty.font.family = "DroidSansM Nerd Font";
base.git.name = "Hung"; base.git.name = "Hung";
base.git.email = "htran@egihosting.com"; base.git.email = "htran@egihosting.com";
} }
@ -232,23 +231,6 @@
}; };
}; };
}; };
# NOTE: This is never actually tested. This is for Ubuntu@Felia
# "ubuntu_admin" = home-manager.lib.homeManagerConfiguration {
# inherit pkgs;
# modules = [
# ./home.nix
# ];
# extraSpecialArgs = {
# myLib = lib;
# myHome = {
# username = "ubuntu_admin";
# homeDirectory = "/home/ubuntu_admin";
# shellInitExtra = ''
# '' + x11_wsl;
# };
# };
# };
# Personal laptop # Personal laptop
hwtr = home-manager.lib.homeManagerConfiguration { hwtr = home-manager.lib.homeManagerConfiguration {
inherit pkgs; inherit pkgs;

View File

@ -0,0 +1,9 @@
{inputs, cell}: {
nerd_font_module = {config, pkgs, ...}: {
fonts.fontconfig.enable = true;
home.packages = [
(pkgs.nerdfonts.override { fonts = [ "Hack" ]; })
];
base.alacritty.font.family = "Hack Nerd Font Mono";
};
}

110
scripts/vim_dsl.py Executable file
View File

@ -0,0 +1,110 @@
#!/usr/bin/env python3 # A simple playground to explore vim plugins that are available in nixpkgs
import csv
import urllib.request
from io import StringIO
import sqlite3
UPSTREAM_CSV = "https://raw.githubusercontent.com/NixOS/nixpkgs/master/pkgs/applications/editors/vim/plugins/vim-plugin-names"
def load_csv(url):
with urllib.request.urlopen(url) as response:
data = response.read().decode()
return csv.DictReader(StringIO(data))
class VimPlugins:
def __init__(self, url: str, sqlite: str = ":memory:"):
self.conn = sqlite3.connect(sqlite)
csv_data = load_csv(url)
fieldnames = csv_data.fieldnames or ["repo", "branch", "alias"]
cur = self.create_table()
for row in csv_data:
fields = ", ".join(f'"{row[field]}"' for field in fieldnames)
cur.execute(f"INSERT INTO {self.table_name()} VALUES ({fields})")
self.conn.commit()
def create_table(self, cursor=None):
cur = self.conn.cursor() if not cursor else cursor
cur.execute(f'''
CREATE TABLE {self.table_name()} (
"repo" TEXT,
"branch" TEXT,
"alias" TEXT
);
''')
return cur
def table_name(self):
return "vim_plugins"
def query(self, query: str):
return self.conn.cursor().execute(query).fetchall()
def vim_plugin_slug(name: str):
return name.replace(".", "-").lower()
def name_from_repo(repo: str):
spl = repo.split("/")
return vim_plugin_slug(spl[-1] or spl[-2])
if __name__ == "__main__":
# REPL zone
vp = VimPlugins(UPSTREAM_CSV)
need_install_plugins = """
tjdevries/nlua.nvim
yioneko/nvim-yati
nathanalderson/yang.vim
numToStr/Comment.nvim
lewis6991/gitsigns.nvim
tpope/vim-fugitive
williamboman/mason.nvim
williamboman/mason-lspconfig.nvim
TimUntersberger/neogit
folke/trouble.nvim
tpope/vim-dispatch
clojure-vim/vim-jack-in
radenling/vim-dispatch-neovim
gennaro-tedesco/nvim-jqx
kylechui/nvim-surround
simrat39/inlay-hints.nvim
gruvbox-community/gruvbox
nvim-lualine/lualine.nvim
lukas-reineke/indent-blankline.nvim
kyazdani42/nvim-web-devicons
m-demare/hlargs.nvim
folke/todo-comments.nvim
nvim-treesitter/playground
saadparwaiz1/cmp_luasnip
L3MON4D3/LuaSnip
arthurxavierx/vim-caser
~/local_repos/ts-ql
""".split()
need_install_plugins = [plugin.strip() for plugin in need_install_plugins if plugin.strip()]
# Create the GitHub URL list
need_install_plugins_gh = [
f"https://github.com/{plugin}/".lower() for plugin in need_install_plugins if not plugin.startswith(("~", "."))]
# Get the values from the database
values = vp.query(f"SELECT LOWER(repo), alias from {vp.table_name()}")
# Check if the repo is in the list of plugins
need_install = [
vim_plugin_slug(alias) if alias else name_from_repo(repo) for repo, alias in values if repo in need_install_plugins_gh]
print("need_install")
print("\n".join(need_install))
# Check if the repo is not in the list
repos = [repo for repo, _ in values]
not_in_repo = [name_from_repo(gh) for gh in need_install_plugins_gh if gh not in repos]
print("not in repo", not_in_repo) # nvim-yati, yang-vim, Comment-nvim, inlay-hints-nvim, hlargs-nvim, vim-caser, gruvbox-community