GithubHelp home page GithubHelp logo

rafaeldelboni / cajus-nvim Goto Github PK

View Code? Open in Web Editor NEW
164.0 4.0 21.0 121.39 MB

Basic config to transform your NVIM in a powerful Clojure IDE using fennel, clojure-lsp and conjure.

License: The Unlicense

Fennel 94.57% Lua 5.43%
nvim fennel lsp clojure nvim-cmp aniseed packer

cajus-nvim's Introduction

Archiving this project

This project will be archived as the author of Aniseed is making a significant change to how Fennel is used and creating the nfnl project.

A new fennel based configuration based on this is being evaluated to in the future to replace this project.

If you want to test the new setup please check it on cajus-nfnl

cajus-nvim

A curvy and juicy neovim configuration following the "Keep it simple!" design principle.

What is this?

Setup config to transform your NVIM in a powerful Clojure IDE using fennel, clojure-lsp and conjure.

Prerequisites

Things you need installed in your OS to use this setup

How to use

Make sure you backup your current configuration files in $HOME/.config/nvim BEFORE running this.

Run these commands in the root of this repo:

# Delete the current nvim config
rm -rf $HOME/.config/nvim

# Makes a symbolic link to the files in this repo
ln -sf $PWD/.config/nvim $HOME/.config/nvim

When you start nvim for the first time it will download packer and aniseed and show some errors, thats normal press enter to ignore and go to the nvim console pressing : and type PackerInstall. This will install all plugins declared in fnl/config/plugin.fnl, after packer's panel showing all the plugins where installed, close nvim and open it again, no errors should show up this time.

Plugins

  • packer Plugin/package management
  • aniseed Bridges between fennel and nvim
  • conjure Interactive repl based evaluation for nvim
  • telescope Find, Filter, Preview, Pick
  • treesitter Incremental parsing system for highlighting, indentation, or folding
  • nvim-lspconfig Quickstart configurations for the Nvim LSP client
  • nvim-cmp Autocompletion plugin
  • tokyonight-nvim A clean, dark Neovim theme written in Lua
  • tpope-vim-sexp-bundle sexp mappings for regular people
  • lualine neovim statusline plugin written in pure lua
  • luasnip Snippet Engine for Neovim written in Lua.

Using with other languages

Files

Wrapper responsible for two things:

  • Download and setup our package manager (packer.nvim) and our fennel helper/interface (aniseed)
  • Set the entrypoint for NVIM read our config files, in our case fnl/config/init.fnl.
  • Set basic global vim configurations and general keymaps.
  • Load plugin configuration namespace.

In this file among other settings I do set the leader key as space and local-leader as , for the sake of the examples of how use this configuration I will use this as basis for the commands.

Here we define the plugins we want packer to download and load for us, we define here a private function called use which will search in the plugin map for the keyword :mod and load the namespace defined in its value.

For example in the line we define that we need telescope we have this map:

  :nvim-telescope/telescope.nvim {:requires [:nvim-lua/popup.nvim
                                             :nvim-lua/plenary.nvim]
                                  :mod :telescope}

This will state to packer download nvim-telescope/telescope.nvim and all the required plugins in :requires and search for the namespace telescope in file located in the following path fnl/config/plugin/telescope, where I usually add plugin specific configuration like keymaps and settings.

Conjure specifics settings, I like to remap the doc work keymap to be <localleader>K instead the only K, to not conflict with the LSP docs K.

Settings like ignore node_modules and everything in .gitignore to be listed in the file finder. Keymaps:

  • <leader>ff open the find files
  • <leader>fg open the fuzzy finder
  • <leader>fb open the find open buffer
  • <leader>fh open the nvim help fuzzy finder

Settings to select which treesitter's features we want enabled and which language extension we want to ensure they will be always installed.

All about nvim's lsp settings and keymaps.

Settings:

  • In the first session, we define which symbols to show for lsp diagnostics.
  • Later we describe which features and server settings we want to enable/customize.
    • Handler defines features and how we want to render the server outputs.
    • Capabilities we link with our autocompletion plugin (nvim-cmp), to say to the lsp servers that we have this feature enabled.
    • On_Attach we customize our interaction with the LSP server, here we define the following keymaps:
      • gd Go to definition
      • K Show documentations
      • <leader>ld Function declarations
      • <leader>lt Type Definitions
      • <leader>lh Signature Help
      • <leader>ln Rename
      • <leader>le Show line diagnostics
      • <leader>lq Show all diagnostics information
      • <leader>lf Auto format
      • <leader>lj Go to next diagnostic
      • <leader>lk Go to previous diagnostic
      • <leader>la Open code actions menu (Using telescope plugin interface)
      • <leader>la Open code actions menu for the selected text in VISUAL mode (Using telescope plugin interface)
      • <leader>lw Open workspace diagnostics list (Using telescope plugin interface)
      • <leader>lr Show all references list for item under the cursor (Using telescope plugin interface)
      • <leader>lr Show all implementations list for item under the cursor (Using telescope plugin interface)
  • Lastly we configure to use all settings above in clojure-lsp server instance.

Here settings of which sources we want to show up in the autocomple menu like (conjure, lsp, buffer) and some mapping to navigate in the menu.

Theme settings like style and comment style.

Settings for vim-sexp like enabling it for another lisp languages like Fennel and Jannet

Settings for lualine status line like some theme overides and setting what will be shown in the line.

Features

Some gifs showing how it works.

Telescope - Find Files

telescope-find-files <leader>ff

Lsp - Loading

lsp-loading on startup

Lsp - Syntax check

lsp-syntax-check <leader>le

Lsp - Go to definition

lsp-go-to-definition gd

Lsp - Document/Signature Help

lsp-document K/<leader>lh

Lsp - Find definition/references

lsp-find-references <leader>lr

Lsp - Formatting

lsp-format <leader>lf

Lsp - Code actions

lsp-code-actions <leader>la

Lsp - Refactorings

lsp-refactorings <leader>la

Lsp - Rename

lsp-rename <leader>ln

Conjure - Eval

conjure-eval <localleader>er

Conjure - Repl

conjure-repl <localleader>lv

Conjure - Document

conjure-document <localleader>K

Completion

auto-complete

Etymology

Cajus is the Portuguese for cashews, which is a fitting name because the format of its nuts reminded me of a parenthesis.

Contributing

If you find any dead links, misinformation or any improvements in this documents at all Emails, PRs and Issues are highly encouraged.

License

This is free and unencumbered software released into the public domain. For more information, please refer to http://unlicense.org

cajus-nvim's People

Contributors

practicalli-johnny avatar rafaeldelboni avatar sandudorogan avatar vloth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cajus-nvim's Issues

Permission to use this repository configuration and content for Practicalli Neovim

With your permission I'd like to use this configuration as the basis for the Neovim setup in the online book Practicalli Neovim. The book is still in very early stages, but would cover the Neovim setup in detail (base on your config with some other additions - which I can contribute back as PRs if desirable).

There is also a rough section on using Neovim on an ultra-portable development environment (android smart phone with termux and Keyboard.io Atreus mechanical keyboard)

The book would also go into detail on using Neovim in general and for specific development tasks, mostly focused on Clojure.

I'd also like to add more plugins, such as which-key and a magit-like git client, as well as convienient key bindings to provide a similar level of features covered in the Practicalli Spacemacs book.

I would naturally give full credit to all the work you have done and add any links you wish, such as a GitHub sponsors link.

All Practicalli on-line books are non-commercial and available under a creative commons license.

Please let me know if you have any concerns.

Clojure lsp connects only if open clojure file from project root

I noticed that lsp works only when I open vim from terminal from the root of the project.

For example, this works:

╭─m1@air in ~ 
╰$ cd IdeaProjects/clojure/play 
╭─m1@air in ~/IdeaProjects/clojure/play 
╰$ vim src/dumch/play.clj 

And this doesn't:

╭─m1@air in ~ 
╰$ vim IdeaProjects/clojure/play/src/dumch/play.clj 

and running this in vim :cd IdeaProjects/clojure/play
: lua print(vim.inspect(vim.lsp.buf_get_clients())) returns {}

How to use community snippets add and add personal snippets

Would it be possible to add documentation on how to use snippets with the configuration?

Specifically I would like to add personal snippets that support markdown content and mkdocs extensions.

I would also like to evaluate community snippets such as rafamadriz/friendly-snippets but it is unclear how these can be added. Simply adding friendly snippets as a plugin in plugin.fnl does not include these snippets.

I have tried adding a snippets directory in the .config/nvim/ directory and copied markdown snippets from vim-snippets which seem to appear in the TAB completion list, although they do not expand.

In fnl/config/plugion/cmp.fnl several sources for autocompletion are defined, although it is unclear what these source specifically refer to for buffer, vsnip and luasnip

(def- cmp-src-menu-items
  {:buffer "buff"
   :conjure "conj"
   :nvim_lsp "lsp"
   :vsnip "vsnp"
   :luasnip "lsnp"})

In Luasnip it discusses loaders, so curious to understand if these loaders are used or relevant to the fennel configuration

What are the supported approaches for snippets in the current configuration, or how could it be extended to support custom snippets?

Thank you

Inserting multiple strings in succession + scrolling the doc popup

First of all, thanks a lot for the repo! Made it very easy for me to switch from CoC to native LSP. Also editing $MYVIMRC is pretty fun when you can evaluate it straight away without any binds to source the file etc.

I wanted to ask a couple of questions which I was unable to figure out on my own:

With my old setup, I could write a list of strings like this:

  1. Type a [ -> nvim completes it to [|] and inserts the cursor between the brackets
  2. Type " to start writing a string out, nvim again completes it to ["|"] and I can begin typing a string
  3. After typing a string, e.g. ["hello|"], and I want to insert another string, I could type a " again, and the result would be like this: ["hello" "|"]

The process works just the same until this point: ["hello|"] . Typing another starting quote will end up like this ["hello "|" "] , which breaks the existing string and is a bit annoying to fix. I have no idea if it's possible to change this behavior to match what it was before , it's just something I noticed after a bit.

Also, I was unable to scroll the documentation popup, which appears by pressing K or <Leader>K. If I understood correctly, in the cmp config it seems like Ctrl+d and Ctrl+f are used for scrolling the documentation window. I'm not sure if it's due to my environment (using Windows Terminal with Ubuntu 20.04), or some existing keybind which prevents them from working or what. For example, pressing Ctrl+d after opening the doc popup, my cursor will just go down half a screen, which I think is its default behavior.

Anyways, maybe you happen to know some fixes off the top of your head or not, but these were some things I found which bothered me and decided to ask 😄

clojure-lsp in neovim is not navigating to function definitions/namespaces

I'm using neovim with clojure lsp for clojure development. My neovim config are exactly same as this repo.

The autosuggesting is working fine with this configuration. But when I like to navigate to function/namespace definitions, it is not working.

For example, I've local repository which it in github here. Let's say I'm working on the file src/clj/guestbook/routes/home.clj. I'm trying to click and navigate to save-message! in line 39. But command + click or ctrl + click is not working. The link is here.

Similarly when I try to navigate the namespaces, command + click is enabled as in the image.

But when I click the namespace, it open the browser with link guestbook.middleware as in the image.

I've asked the same question in the stackoverflow as well

Contributing plugins - what would be of interest

Which of the following plugins would be of used to contribute as pull requests to this configuration

  • telescope-file-browser - browse, create, rename, delete files and directories throughout the filespace (I find this very useful)
  • telescope-env - list environment variables
  • nvim-tree - visual file system browser (Lua version of Nerdtree)
  • todo-comments - highlight TODOD, FIXME, etc in buffers
  • startup.nvim - themes to load when nvim started without a file
  • numb.nvim - peek at a line number
  • nvim-comment - toggle line comments with visual select and motions

I have been using these for a few days in my experimental configuration and they seem to work. There are some other plugins that are interesting, but still evaluating those.

completions not selectable - snippet engine not configured

Although I get completion menus when I type in neovim, I am unable to select (using TAB or arrow keys) from the completion menu.

When I type a snippet (i.e. comment-header from Clojure LSP snippets) out in full and use TAB to expand the snippet, then I get the following error (shown by calling :mes)

E5108: Error executing lua ...te/pack/packer/start/nvim-cmp/lua/cmp/config/default.lua:23: snippet engine is not configured.                                                                                                                                                                                          
stack traceback:                                                                                                                                                                                                                                                                                                      
        [C]: in function 'error'                                                                                                                                                                                                                                                                                      
        ...te/pack/packer/start/nvim-cmp/lua/cmp/config/default.lua:23: in function 'expand'                                                                                                                                                                                                                          
        ...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/core.lua:450: in function <...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/core.lua:411>                                                                                                                                                                
        ...te/pack/packer/start/nvim-cmp/lua/cmp/utils/feedkeys.lua:47: in function <...te/pack/packer/start/nvim-cmp/lua/cmp/utils/feedkeys.lua:45>

The completions popup no longer shows with any suggestions after this error.

I get the same results on recent MacOSX version and Ubnutu Linux, using Neovim 7 and installed this configuration about a week ago (I'll try and update next).

I will try and recreate this issue with a simple Clojure project that I can share, although I dont recall the snippets ever working.

Thank you.

How to show LSP's diagnostic error code

Great work on opening up a config using fennel :)

Seeing your examples, I was wondering how did you display LSP's diagnostic error code as shown here:

Screen Shot 2023-07-19 at 15 34 11

Cheers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.