personalize 💅

This commit is contained in:
Talon 2023-07-28 08:26:18 -06:00
parent 029696e080
commit c83646d603
10 changed files with 132 additions and 120 deletions

View file

@ -1,6 +1,6 @@
# NeoMacs
# NeoVS (aka NeoMacs)
I've never used emacs but thanks to fennel I've been enlightened by LISP.
It behaves like VSCodium but it's configured with a LISP.
## How
@ -10,9 +10,10 @@ I've never used emacs but thanks to fennel I've been enlightened by LISP.
## Features
- Syntax highlighting via [Treesitter](https://github.com/nvim-treesitter/nvim-treesitter)
- Language Server Protocols via [Mason](https://github.com/williamboman/mason.nvim)
- Fuzzy finding via [Telescope](https://github.com/nvim-telescope/telescope.nvim)
- Syntax highlighting via [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter)
- Language Server Protocols via [mason](https://github.com/williamboman/mason.nvim)
- Fuzzy finding via [telescope](https://github.com/nvim-telescope/telescope.nvim)
- Completion and snippets via [nvim-cmp](https://github.com/hrsh7th/nvim-cmp)
## Dependencies
@ -36,3 +37,4 @@ Inside Neovim this is useful:
- [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter)
- [mason](https://github.com/williamboman/mason.nvim)
- [telescope](https://github.com/nvim-telescope/telescope.nvim)
- [nvim-cmp](https://github.com/hrsh7th/nvim-cmp)

View file

@ -1,46 +0,0 @@
;; Autocompletion and Snippets with nvim-cmp and luasnip
(let
[cmp (require :cmp)
luasnip (require :luasnip)
vscode-snips (require :luasnip.loaders.from_vscode)
]
(vscode-snips.lazy_load)
(luasnip.config.setup)
(cmp.setup
{:snippet {:expand #(luasnip $1)}
:mapping (cmp.mapping.preset.insert
{:<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])})
: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}])
}))

View file

@ -1,9 +0,0 @@
(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 live_grep")
(nmap "<C-B>" ":Telescope buffers<CR>" "Telescope buffers")
(nmap "<C-T>" ":Telescope treesitter<CR>" "Telescope treesitter"))

View file

@ -51,8 +51,10 @@
(let [telescope (require :telescope)]
(pcall (telescope.load_extension :fzf)))
(require :treesitter-setup)
(require :mason-setup)
(require :cmp-setup)
(require :options)
(require :custom-keys)
(require :setup-treesitter)
(require :setup-mason)
(require :setup-cmp)
(let [personalize (require :personalize)]
(personalize.keymap)
(personalize.options))

View file

@ -1,51 +0,0 @@
;; Language Server Protocols via Mason
(let
[neodev (require :neodev)
mason (require :mason)
mason-lspconfig (require :mason-lspconfig)
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]}
}
on_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")
(vim.api.nvim_buf_create_user_command bufnr "Format"
#(vim.lsp.buf.format)
"Format current buffer with LSP")))
]
(neodev.setup)
(mason.setup)
(mason-lspconfig.setup {:ensure_installed (vim.tbl_keys servers)})
(mason-lspconfig.setup_handlers
[(fn [server_name] (let
[server (. (require :lspconfig) server_name)
cmp-nvim-lsp (require :cmp_nvim_lsp)
settings (. servers server_name)
]
(server.setup
{:capabilities (cmp-nvim-lsp.default_capabilities (vim.lsp.protocol.make_client_capabilities))
:on_attach on_attach
:settings settings
:filetypes (or settings.filetypes [])})))
]))

View file

@ -1,4 +0,0 @@
(set vim.o.termguicolors true)
(set vim.o.mouse :a)
(set vim.o.clipboard :unnamedplus)
(vim.cmd.colorscheme :everforest)

62
fnl/personalize.fnl Normal file
View file

@ -0,0 +1,62 @@
(let
[cmp (require :cmp)
luasnip (require :luasnip)
]
{:keymap (fn []
(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")
(nmap "<C-P>" ":Telescope find_files<CR>" "Telescope find_files")
(nmap "<C-F>" ":Telescope live_grep<CR>" "Telescope live_grep")
(nmap "<C-B>" ":Telescope buffers<CR>" "Telescope buffers")
(nmap "<C-T>" ":Telescope treesitter<CR>" "Telescope treesitter")))
:options (fn []
(set vim.o.termguicolors true)
(set vim.o.mouse :a)
(set vim.o.clipboard :unnamedplus)
(vim.cmd.colorscheme :everforest))
:personal-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])}
: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]}}
: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")
(vim.api.nvim_buf_create_user_command bufnr "Format"
#(vim.lsp.buf.format)
"Format current buffer with LSP")))
})

33
fnl/setup-cmp.fnl Normal file
View file

@ -0,0 +1,33 @@
;; Autocompletion and Snippets with nvim-cmp and luasnip
(let
[cmp (require :cmp)
luasnip (require :luasnip)
vscode-snips (require :luasnip.loaders.from_vscode)
{: personal-cmp-mapping} (require :personalize)
]
(vscode-snips.lazy_load)
(luasnip.config.setup)
(cmp.setup
{:snippet {:expand #(luasnip $1)}
:mapping (cmp.mapping.preset.insert personal-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}])
}))

23
fnl/setup-mason.fnl Normal file
View file

@ -0,0 +1,23 @@
;; language server protocols via mason
(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 settings
:filetypes (or settings.filetypes [])})))
]))