Compare commits

..

1 commit

Author SHA1 Message Date
Talon 6308be20b8 failed WIP 2023-07-27 08:36:27 -06:00
13 changed files with 97 additions and 366 deletions

View file

@ -11,15 +11,6 @@ quote_style = double
[*.lua] [*.lua]
# [basic] # [basic]
# optional space/tab
indent_style = space
# if indent_style is space, this is valid
indent_size = 2
# if indent_style is tab, this is valid
tab_width = 2
# none/single/double
quote_style = none
continuation_indent = 4 continuation_indent = 4
# this mean utf8 length , if this is 'unset' then the line width is no longer checked # this mean utf8 length , if this is 'unset' then the line width is no longer checked

3
.gitignore vendored
View file

@ -1,3 +0,0 @@
shada
log
tags

View file

@ -1,34 +0,0 @@
# Scheme/Lisp Flavored NeoVim
Configuration via [fennel](https://fennel-lang.org). Tuned for s-expressions and prose.
## Features
- **`fnl/personalize` has all the tweakable bits**
- s-expression power editing via [vim-sexp](https://github.com/guns/vim-sexp), [for regular people](https://github.com/tpope/vim-sexp-mappings-for-regular-people)
- [vim-markdown](https://github.com/preservim/vim-markdown) and [Obsidian](https://github.com/epwalsh/obsidian.nvim) powered notes.
- Fuzzy finding via [telescope](https://github.com/nvim-telescope/telescope.nvim)
- Syntax highlighting via [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter)
- Completion and snippets via [nvim-cmp](https://github.com/hrsh7th/nvim-cmp)
- Language Server Protocols via [mason](https://github.com/williamboman/mason.nvim)
## How
- [hotpot](https://github.com/rktjmp/hotpot.nvim) is downloaded if not found via `init.lua` (to the `lazy` packages folder so it can be managed from there later)
- `fnl/plugins.fnl` is required from `init.lua` which wires up
- [`lazy.nvim`](https://github.com/folke/lazy.nvim) for package management `:Lazy`
## Dependencies
Some of the packages/hotkeys use:
- cmake
- cargo
- npm
- ripgrep
- fd
- tig
- newsboat
Inside Neovim this is useful:
```neovim
:checkhealth
```
## See Also
- [Neovim and Lua](https://neovim.io/doc/user/lua.html#Lua)

9
fnl/custom-keys.fnl Normal file
View file

@ -0,0 +1,9 @@
(let [nmap #(vim.keymap.set :n $1 $2 {:desc "$3"})]
(nmap "<Tab>" ":bnext<CR>" "Next Buffer")
(nmap "<S-Tab>" ":bprevious<CR>" "Previous Buffer")
(nmap "<C-X>" ":write|bdelete<CR>" "Save and delete buffer")
;; fuzzy finding
(nmap "<C-P>" ":Telescope find_files<CR>" "Telescope find_files")
(nmap "<C-F>" ":Telescope live_grep<CR>" "Telescope find_files")
(nmap "<C-B>" ":Telescope buffers<CR>" "Telescope find_files")
)

3
fnl/init.fnl Normal file
View file

@ -0,0 +1,3 @@
(require :lazy-setup)
(require :options)
(require :custom-keys)

34
fnl/lazy-setup.fnl Normal file
View file

@ -0,0 +1,34 @@
(let [lazypath (.. (vim.fn.stdpath "data") "/lazy/lazy.nvim")]
(if (not (vim.loop.fs_stat lazypath))
(vim.fn.system
["git"
"clone"
"--filter=blob:none"
"https://github.com/folke/lazy.nvim.git"
"--branch=stable"
lazypath]))
(vim.opt.rtp:prepend lazypath))
(let [lazy (require :lazy)]
(lazy.setup
["https://github.com/rktjmp/hotpot.nvim"
{:url "https://github.com/nvim-telescope/telescope.nvim"
:tag "0.1.2"
:dependencies ["nvim-lua/plenary.nvim"]}
{:url "https://github.com/nvim-telescope/telescope-fzf-native.nvim"
:build (.. "cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release"
" && cmake --build build --config Release"
" && cmake --install build --prefix build" )}
{:url "https://github.com/neovim/nvim-lspconfig"
:dependencies
["https://github.com/williamboman/mason.nvim"
"williamboman/mason-lspconfig.nvim"
{:url "https://github.com/j-hui/fidget.nvim"
:tag "legacy"
:opts {}}
"folke/neodev.nvim"
]}
]))
(let [telescope (require "telescope")]
(pcall (telescope.load_extension :fzf)))

3
fnl/options.fnl Normal file
View file

@ -0,0 +1,3 @@
(set vim.o.termguicolors true)
(set vim.o.mouse :a)
(set vim.o.clipboard :unnamedplus)

View file

@ -1,142 +0,0 @@
(let [cmp (require :cmp)
luasnip (require :luasnip)]
{:options (fn []
(set vim.g.mapleader " ")
(set vim.g.maplocalleader "\\")
(set vim.o.termguicolors true)
(set vim.opt.clipboard :unnamedplus)
(set vim.o.wrap false)
(set vim.opt.colorcolumn "80,120")
(vim.cmd.colorscheme :quiet)
(set vim.o.formatoptions :tncro)
(set vim.o.conceallevel 2) ;; 🤞 for anticonceal
(set vim.o.foldlevel 1)
(set vim.o.splitbelow true)
(set vim.o.splitright true)
(set vim.opt.swapfile false)
(set vim.g.sexp_filetypes "racket,fennel,scheme,lisp"))
:keymap (fn []
(let [nmap #(vim.keymap.set :n $1 $2 {:desc $3})
tmap #(vim.keymap.set :t $1 $2 {:desc (.. $3 " (from a terminal)")})]
(nmap :<C-h> :<C-W>h
"Move to window left")
(tmap :<C-h> :<C-\><C-n><C-w>h
"Move to window left")
(nmap :<C-j> :<C-W>j
"Move to window down")
(tmap :<C-j> :<C-\><C-n><C-w>j
"Move to window down")
(nmap :<C-k> :<C-W>k
"Move to window up")
(tmap :<C-k> :<C-\><C-n><C-w>k
"Move to window up")
(nmap :<C-l> :<C-W>l
"Move to window right")
(tmap :<C-l> :<C-\><C-n><C-w>l
"Move to window right")
(tmap :<C-w> "<C-\\><C-n>"
"Escape to normal mode")
(nmap :<C-x> ":bn|bd!#<cr>"
"Delete a buffer without removing the split")
(nmap :<leader>tt ":term<cr>i"
"Open a terminal in the current window")
(nmap :<leader>to ":new term://bash|resize 8<cr>"
"Open an 8 line terminal below the current window")
(nmap :<leader>w :80<C-W>|
"Set the window width to 80 characters")
(nmap :<leader>W :120<C-W>|
"Set the window width to 120 characters")
(nmap :<C-w>t ":tabnew<cr>"
"Create a new tab page")
(tmap :<C-w>t "<C-\\><C-n>:tabnew<cr>"
"Create a new tab page")
(nmap :<C-w><tab> :<C-w>gt
"Go to next tab (cyclical)")
(tmap :<C-w><tab> :<C-w>gt
"Go to next tab (cyclical)")
(nmap :<leader>oo ":tcd ~/TDC-Obsidian/|edit WIP.md<cr>"
"Open Obsidian")
(nmap :<leader>ot ":ObsidianToday<cr>"
"Open daily journal")
(nmap :<leader>of ":ObsidianOpen<cr>"
"Open this file in the Obsidian app")
(nmap :<leader>p ":Telescope commands<cr>"
"Search commands")
(nmap :<leader>ff ":Telescope find_files<cr>"
"Search filenames in :pwd")
(nmap :<leader>fb ":Telescope buffers<cr>"
"Search open buffers")
(nmap :<leader>fs ":Telescope live_grep<cr>"
"Search current buffer")
(nmap :<leader>fe ":Telescope emoji<cr>"
"Search for an emoji to copy to clipboard")
(nmap :<leader>gs ":edit term://tig<cr>i"
"Open tig(1) to stage and commit changes")
(nmap :<leader>gn ":edit term://newsboat<cr>i"
"Open newsboat(1)")
(let [duck (require :duck)]
(nmap :<leader><leader> #(duck.hatch) "hatch a duck")
(nmap :<leader>dk #(duck.cook) "cook a duck"))))
:obsidian {:workspaces [{:name "TDC-Obsidian"
:path "/home/specter/TDC-Obsidian"}]
:daily_notes {:folder "Journal/"
:date_format "%Y/%m/%Y-%m-%d"}
:disable_frontmatter true
:ui {
:enable true
:checkboxes {
" " {:char "⬜" :hl_group "ObsidianTodo"}
"x" {:char "✔️" :hl_group "ObsidianDone"}}
:external_link_icon {:char "↗️" :hl_group "ObsidianExtLinkIcon"}}
:wiki_link_func "prepend_note_id"
:follow_url_func (lambda [url] (vim.fn.jobstart ["xdg-open" url]))}
:treesitter-languages [:c :lua :vim :vimdoc :query :fennel :racket]
:language-servers {:lua_ls {:filetypes [:lua]
:Lua {:workspace {:checkThirdParty false}}
:telemetry {:enable false}
:diagnostics {:globals [:vim]}}
:fennel_language_server {:filetypes [:fennel]
:fennel {:workspace {:library (vim.api.nvim_list_runtime_paths)}
:diagnostics {:globals [:vim]}}}
:bashls {:filetypes [:bash]}
:marksman {:filetypes [:markdown]}}
:lsp-attach (fn [_ bufnr]
(let [nmap #(vim.keymap.set :n $1 $2
{:buffer bufnr
:desc (.. "LSP: " $3)})
telescope (require :telescope.builtin)]
(nmap :gd vim.lsp.buf.definition "[G]o to [D]efiniton")
(nmap :gr telescope.lsp_references "[G]o to [R]eferences")
(nmap :gI vim.lsp.buf.implementation
"[G]o to [I]mplementation")))
:cmp-mapping {:<C-j> (cmp.mapping.select_next_item)
:<C-k> (cmp.mapping.select_prev_item)
:<C-d> (cmp.mapping.scroll_docs -4)
:<C-f> (cmp.mapping.scroll_docs 4)
:<C-Space> (cmp.mapping.complete)
:<CR> (cmp.mapping.confirm {:behavior cmp.ConfirmBehavior.Replace
:select true})
:<Tab> (cmp.mapping (fn [fallback]
(if (cmp.visible) (cmp.select_prev_item)
(luasnip.expand_or_locally_jumpable) (luasnip.expand_or_jump)
(fallback)))
[:i :s])
:<S-Tab> (cmp.mapping (fn [fallback]
(if (cmp.visible)
(cmp.select_prev_item)
(luasnip.locally_jumpable -1)
(luasnip.jump -1) (fallback)))
[:i :s])}})

View file

@ -1,105 +0,0 @@
;; FIXME: This belongs in personalize.fnl It's also here because it fixes a bug with racket filetypes...
(set vim.g.sexp_filetypes "racket,fennel,scheme,lisp")
(let [lazy (require :lazy)]
(lazy.setup ["https://github.com/rktjmp/hotpot.nvim"
"https://github.com/tpope/vim-sexp-mappings-for-regular-people"
"https://github.com/guns/vim-sexp"
"https://github.com/benknoble/vim-racket"
"https://github.com/preservim/vim-markdown"
{:url "https://github.com/epwalsh/obsidian.nvim"
:version "v3.7.1"}
"https://github.com/nvim-lua/plenary.nvim"
{:url "https://github.com/nvim-treesitter/nvim-treesitter"
:build ":TSUpdate"}
{:url "https://github.com/neovim/nvim-lspconfig"
:dependencies ["https://github.com/williamboman/mason.nvim"
:williamboman/mason-lspconfig.nvim
{:url "https://github.com/j-hui/fidget.nvim"
:tag :legacy
:opts {}}
"https://github.com/folke/neodev.nvim"]}
{:url "https://github.com/hrsh7th/nvim-cmp"
:dependencies ["https://github.com/hrsh7th/cmp-nvim-lsp"
"https://github.com/hrsh7th/cmp-buffer"
"https://github.com/hrsh7th/cmp-path"
"https://github.com/hrsh7th/cmp-cmdline"
"https://github.com/hrsh7th/cmp-cmdline"]}
{:url "https://github.com/L3MON4D3/LuaSnip"
:dependencies ["https://github.com/saadparwaiz1/cmp_luasnip"
"https://github.com/rafamadriz/friendly-snippets"]}
{:url "https://github.com/nvim-telescope/telescope.nvim"
:tag :0.1.2
:dependencies [{:url "https://github.com/nvim-telescope/telescope-fzf-native.nvim"
:build (.. "cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release"
" && cmake --build build --config Release"
" && cmake --install build --prefix build")}
"https://github.com/xiyaowong/telescope-emoji.nvim"]}
"https://github.com/tamton-aquib/duck.nvim"]))
;; NOTE: If a value could be considered a preference or is subjective
;; then it should be defined in personalize.fnl
;; Otherwise packaging details and less malleable values, by nature or desire, belong below...
(let [personalize (require :personalize)]
(personalize.options)
(personalize.keymap))
(let [telescope (require :telescope)]
(pcall (telescope.load_extension :fzf))
(pcall (telescope.load_extension :emoji)))
(let [cmp (require :cmp)
luasnip (require :luasnip)
vscode-snips (require :luasnip.loaders.from_vscode)
{: cmp-mapping} (require :personalize)]
(vscode-snips.lazy_load)
(luasnip.config.setup)
(cmp.setup {:snippet {:expand #(luasnip $1)}
:mapping (cmp.mapping.preset.insert cmp-mapping)
:sources (cmp.config.sources [{:name :nvim_lsp}
{:name :luasnip}
{:name :buffer}])})
(cmp.setup.cmdline ["/" "?"]
{:mapping (cmp.mapping.preset.cmdline)
:sources [{:name :buffer}]})
(cmp.setup.cmdline [":"]
{:mapping (cmp.mapping.preset.cmdline)
:sources (cmp.config.sources [{:name :path}
{:name :cmdline}])})
(cmp.setup.filetype [:gitcommit]
{:mapping (cmp.mapping.preset.cmdline)
:sources (cmp.config.sources [{:name :git}
{:name :buffer}])}))
(let [obsidian (require :obsidian)
personalize (require :personalize)]
(obsidian.setup personalize.obsidian))
(let [treesitter (require :nvim-treesitter.configs)
{: treesitter-languages} (require :personalize)]
(treesitter.setup {:ensure_installed treesitter-languages
:sync_install false
:auto_install true
:highlight {:enable true}
:indent {:enable true}}))
(let [neodev (require :neodev)
mason (require :mason)
mason-lspconfig (require :mason-lspconfig)
{: language-servers : lsp-attach} (require :personalize)]
(neodev.setup)
(mason.setup)
(mason-lspconfig.setup {:ensure_installed (vim.tbl_keys language-servers)})
(mason-lspconfig.setup_handlers
[(fn [server_name]
(let [server (. (require :lspconfig)
server_name)
cmp-nvim-lsp (require :cmp_nvim_lsp)
settings (. language-servers
server_name)]
(server.setup {:capabilities (cmp-nvim-lsp.default_capabilities (vim.lsp.protocol.make_client_capabilities))
:on_attach lsp-attach
: settings
:filetypes (or settings.filetypes
[])})))]))

View file

@ -1,14 +0,0 @@
vim.api.nvim_create_autocmd({ "BufNewFile", "BufFilePost", "BufRead" }, {
pattern = "*.gmi",
callback = function()
vim.bo.filetype = "gemini"
vim.bo.syntax = "gemini"
vim.bo.textwidth = 0
vim.o.colorcolumn = ""
vim.bo.comments = ""
vim.o.wrap = true
vim.o.linebreak = true
vim.keymap.set({"n"}, "j", "gj")
vim.keymap.set({"n"}, "k", "gk")
end,
})

View file

@ -1,15 +0,0 @@
vim.api.nvim_create_autocmd({ "BufNewFile", "BufFilePost", "BufRead" }, {
pattern = "*.md",
callback = function()
vim.bo.filetype = "markdown"
vim.bo.syntax = "markdown"
vim.o.colorcolumn = "80"
vim.bo.textwidth = 0
vim.bo.comments = ""
vim.o.colorcolumn = ""
vim.o.wrap = true
vim.o.linebreak = true
vim.keymap.set({"n"}, "j", "gj")
vim.keymap.set({"n"}, "k", "gk")
end,
})

View file

@ -1,5 +1,3 @@
-- Hotpot enables fennel support
-- https://github.com/rktjmp/hotpot.nvim
local hotpot_path = vim.fn.stdpath('data') .. '/lazy/hotpot.nvim' local hotpot_path = vim.fn.stdpath('data') .. '/lazy/hotpot.nvim'
if vim.fn.empty(vim.fn.glob(hotpot_path)) > 0 then if vim.fn.empty(vim.fn.glob(hotpot_path)) > 0 then
print("Could not find hotpot.nvim, cloning new copy to", hotpot_path) print("Could not find hotpot.nvim, cloning new copy to", hotpot_path)
@ -7,24 +5,45 @@ if vim.fn.empty(vim.fn.glob(hotpot_path)) > 0 then
'https://github.com/rktjmp/hotpot.nvim', hotpot_path}) 'https://github.com/rktjmp/hotpot.nvim', hotpot_path})
vim.cmd("helptags " .. hotpot_path .. "/doc") vim.cmd("helptags " .. hotpot_path .. "/doc")
end end
vim.opt.rtp:prepend(hotpot_path)
-- Lazy is the package manager require("hotpot")
-- https://github.com/folke/lazy.nvim require("init")
local lazy_path = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazy_path) then local servers =
vim.fn.system({ {lua_ls = {Lua = {workspace = {checkThirdParty = false}, telemetry = {enable = false}}}
"git", -- TODO :fennel_language_server {}
"clone", -- TODO :bash_language_server {}
"--filter=blob:none", -- TODO :jq {}
"https://github.com/folke/lazy.nvim.git", }
"--branch=stable", -- latest stable release
lazy_path, local on_attach = function (_, bufnr)
}) local nmap = function (keys, fn, desc)
vim.keymap.set(keys, fn, {buffer = bufnr, desc = desc})
end
local telescope = require("telescope.builtin")
nmap("gd", vim.lsp.buf.definition, "[G]o to [D]efiniton")
nmap("gr", telescope.lsp_references, "[G]o to [R]eferences")
nmap("gI", vim.lsp.buf.implementation, "[G]o to [I]mplementation")
vim.api.nvim_buf_create_user_command(bufnr, "Format", function ()
vim.lsp.buf.format()
end, "Format current buffer with LSP")
end end
vim.opt.rtp:prepend({hotpot_path, lazy_path}) require("neodev").setup()
require("hotpot") require("mason").setup()
-- the rest of this config is written in Fennel local mason_lspconfig = require("mason-lspconfig")
-- https://fennel-lang.org/ mason_lspconfig.setup({ensure_installed = vim.tbl_keys(servers)})
require("plugins") mason_lspconfig.setup_handlers({
function (server_name)
local server = require(server_name)
server.setup({
capabilities = vim.lsp.protocol.make_client_capabilities(),
on_attach = on_attach,
settings = servers[server_name],
filetypes = (servers[server_name] or {}).filetypes,
})
end
})

View file

@ -1,28 +1,13 @@
{ {
"LuaSnip": { "branch": "master", "commit": "a7a4b4682c4b3e2ba82b82a4e6e5f5a0e79dec32" }, "editorconfig.nvim": { "branch": "master", "commit": "5b9e303e1d6f7abfe616ce4cc8d3fffc554790bf" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" },
"cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"duck.nvim": { "branch": "main", "commit": "d8a6b08af440e5a0e2b3b357e2f78bb1883272cd" },
"fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" }, "fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" },
"friendly-snippets": { "branch": "main", "commit": "dcd4a586439a1c81357d5b9d26319ae218cc9479" }, "hotpot.nvim": { "branch": "master", "commit": "026eba9596b506ab6f807fd4aa93cd5f76255725" },
"hotpot.nvim": { "branch": "master", "commit": "b18d3d82e8545d9f765870c1d8f0da041bd61097" }, "lazy.nvim": { "branch": "main", "commit": "3ad55ae678876516156cca2f361c51f7952a924b" },
"lazy.nvim": { "branch": "main", "commit": "83493db50a434a4c5c648faf41e2ead80f96e478" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "e86a4c84ff35240639643ffed56ee1c4d55f538e" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "82c7cb08ddb836ad938b2708e50085f12a8825d2" }, "mason.nvim": { "branch": "main", "commit": "fe9e34a9ab4d64321cdc3ecab4ea1809239bb73f" },
"mason.nvim": { "branch": "main", "commit": "3b5068f0fc565f337d67a2d315d935f574848ee7" }, "neodev.nvim": { "branch": "main", "commit": "f57e5210d450b47aa02ea6d9e50a37414f570b4c" },
"neodev.nvim": { "branch": "main", "commit": "84e0290f5600e8b89c0dfcafc864f45496a53400" }, "nvim-lspconfig": { "branch": "master", "commit": "b6091272422bb0fbd729f7f5d17a56d37499c54f" },
"nvim-cmp": { "branch": "main", "commit": "04e0ca376d6abdbfc8b52180f8ea236cbfddf782" }, "plenary.nvim": { "branch": "master", "commit": "267282a9ce242bbb0c5dc31445b6d353bed978bb" },
"nvim-lspconfig": { "branch": "master", "commit": "4bdd3800b4148f670c6cf55ef65f490148eeb550" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "9bc8237565ded606e6c366a71c64c0af25cd7a50" },
"nvim-treesitter": { "branch": "master", "commit": "f87882858438834d2fbb6379aa2be37de901751b" }, "telescope.nvim": { "branch": "master", "commit": "776b509f80dd49d8205b9b0d94485568236d1192" }
"obsidian.nvim": { "branch": "main", "commit": "b136c1545fb9c4888d37ba482bfc77f222bbdf52" },
"plenary.nvim": { "branch": "master", "commit": "f7adfc4b3f4f91aab6caebf42b3682945fbc35be" },
"telescope-emoji.nvim": { "branch": "master", "commit": "86248d97be84a1ce83f0541500ef9edc99ea2aa1" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "9ef21b2e6bb6ebeaf349a0781745549bbb870d27" },
"telescope.nvim": { "branch": "master", "commit": "776b509f80dd49d8205b9b0d94485568236d1192" },
"vim-markdown": { "branch": "master", "commit": "a657e697376909c41475a686eeef7fc7a4972d94" },
"vim-racket": { "branch": "master", "commit": "eec2017083c302677459b4607a319954d7390b84" },
"vim-sexp": { "branch": "master", "commit": "14464d4580af43424ed8f2614d94e62bfa40bb4d" },
"vim-sexp-mappings-for-regular-people": { "branch": "master", "commit": "cc5923e357373ea6ef0c13eae82f44e6b9b1d374" }
} }