diff --git a/README.md b/README.md index 94a03ad..196f4ea 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/fnl/cmp-setup.fnl b/fnl/cmp-setup.fnl deleted file mode 100644 index 5939a06..0000000 --- a/fnl/cmp-setup.fnl +++ /dev/null @@ -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 - {: (cmp.mapping.select_next_item) - : (cmp.mapping.select_prev_item) - : (cmp.mapping.scroll_docs -4) - : (cmp.mapping.scroll_docs 4) - : (cmp.mapping.complete) - : (cmp.mapping.confirm {:behavior cmp.ConfirmBehavior.Replace :select true}) - : (cmp.mapping (fn [fallback] - (if (cmp.visible) (cmp.select_prev_item) - (luasnip.expand_or_locally_jumpable) (luasnip.expand_or_jump) - (fallback))) [:i :s]) - : (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}]) - })) diff --git a/fnl/custom-keys.fnl b/fnl/custom-keys.fnl deleted file mode 100644 index 9313ba9..0000000 --- a/fnl/custom-keys.fnl +++ /dev/null @@ -1,9 +0,0 @@ -(let [nmap #(vim.keymap.set [:n] $1 $2 {:desc $3})] - (nmap "" ":bnext" "Next Buffer") - (nmap "" ":bprevious" "Previous Buffer") - (nmap "" ":write|bdelete" "Save and delete buffer") - ;; fuzzy finding - (nmap "" ":Telescope find_files" "Telescope find_files") - (nmap "" ":Telescope live_grep" "Telescope live_grep") - (nmap "" ":Telescope buffers" "Telescope buffers") - (nmap "" ":Telescope treesitter" "Telescope treesitter")) diff --git a/fnl/init.fnl b/fnl/init.fnl index 2b48be2..77d75d4 100644 --- a/fnl/init.fnl +++ b/fnl/init.fnl @@ -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)) diff --git a/fnl/mason-setup.fnl b/fnl/mason-setup.fnl deleted file mode 100644 index 289989b..0000000 --- a/fnl/mason-setup.fnl +++ /dev/null @@ -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 [])}))) - ])) - diff --git a/fnl/options.fnl b/fnl/options.fnl deleted file mode 100644 index a3369cb..0000000 --- a/fnl/options.fnl +++ /dev/null @@ -1,4 +0,0 @@ -(set vim.o.termguicolors true) -(set vim.o.mouse :a) -(set vim.o.clipboard :unnamedplus) -(vim.cmd.colorscheme :everforest) diff --git a/fnl/personalize.fnl b/fnl/personalize.fnl new file mode 100644 index 0000000..9010b7e --- /dev/null +++ b/fnl/personalize.fnl @@ -0,0 +1,62 @@ +(let + [cmp (require :cmp) + luasnip (require :luasnip) + ] + {:keymap (fn [] + (let [nmap #(vim.keymap.set [:n] $1 $2 {:desc $3})] + (nmap "" ":bnext" "Next Buffer") + (nmap "" ":bprevious" "Previous Buffer") + (nmap "" ":write|bdelete" "Save and delete buffer") + (nmap "" ":Telescope find_files" "Telescope find_files") + (nmap "" ":Telescope live_grep" "Telescope live_grep") + (nmap "" ":Telescope buffers" "Telescope buffers") + (nmap "" ":Telescope treesitter" "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 + {: (cmp.mapping.select_next_item) + : (cmp.mapping.select_prev_item) + : (cmp.mapping.scroll_docs -4) + : (cmp.mapping.scroll_docs 4) + : (cmp.mapping.complete) + : (cmp.mapping.confirm {:behavior cmp.ConfirmBehavior.Replace :select true}) + : (cmp.mapping (fn [fallback] + (if (cmp.visible) (cmp.select_prev_item) + (luasnip.expand_or_locally_jumpable) (luasnip.expand_or_jump) + (fallback))) [:i :s]) + : (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"))) + }) diff --git a/fnl/setup-cmp.fnl b/fnl/setup-cmp.fnl new file mode 100644 index 0000000..93b0e72 --- /dev/null +++ b/fnl/setup-cmp.fnl @@ -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}]) + })) diff --git a/fnl/setup-mason.fnl b/fnl/setup-mason.fnl new file mode 100644 index 0000000..9ea3d51 --- /dev/null +++ b/fnl/setup-mason.fnl @@ -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 [])}))) + ])) + diff --git a/fnl/treesitter-setup.fnl b/fnl/setup-treesitter.fnl similarity index 100% rename from fnl/treesitter-setup.fnl rename to fnl/setup-treesitter.fnl