Giter Club home page Giter Club logo

clojure.vim's People

Contributors

axvr avatar bk2204 avatar bounceme avatar cemerick avatar deraen avatar dkearns avatar ethewalt avatar guns avatar invertisment avatar jballanc avatar jsn avatar michaelblume avatar mrichards42 avatar noprompt avatar nwjsmith avatar raymond-w-ko avatar sethyuan avatar skanev avatar tchagnon 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

Watchers

 avatar  avatar  avatar  avatar  avatar

clojure.vim's Issues

Is there a way to highlight namespace of a keyword separately?

Hey.
I use CIDER in Spacemacs and they do this:
image

How can I achieve that in vim/nvim?
The default behavior in nvim gives me this:
image

When I try to do define my own syntax for highlighting part of a keyword I can't understand how to do it (copied from this project) and I end up highlighting the whole keyword or nothing at all:

syntax match clojureKeywordMine "\v<:{1,2}([^ \n\r\t()\[\]{}";@^`~\\/]+/)*<!>"
highlight clojureKeywordMine ctermbg=darkred

Port performance improvements to Neovim/Lua

Regarding Neovim, until Vim9 script support is added, the "New (legacy)" code will be used. If anyone would like to volunteer to write a Lua implementation of this code for Neovim please open an issue and we can discuss how to integrate it.

Originally posted by @axvr in #31 (comment)

I'd be willing to try my hand at it.

cljfmt-compatible ns form formatting

Hello,
Currently indent/clojure.vim indents subforms of (ns ...) with 2-spaces, like this:

(ns ncr.nsql.simple
  (:require
    [clojure.string :as str]
    [clojure.core.match :refer [match]]

while the style guide seemingly recommends, and cljfmt indents, the same subforms with 1-space (paren-aligned), like this:

(ns ncr.nsql.simple
  (:require
   [clojure.string :as str]
   [clojure.core.match :refer [match]]

Would you consider accepting a patch that adds optional, off-by-default ability to format those like cljfmt does it?

Create Vim 9 script variant of the new indentation algorithm

Note
Currently waiting on #31 to be completed and merged.

Create a Vim 9 script variant of the new indentation algorithm to get significant performance improves during indentation.

This will be a fairly quick task, the only difficult part is figuring out how to integrate it in a clean way.

(Provide a secret config option to turn off Vim9 script version for testing.)

Neovim equivalent: #32

[Feature Request] Set `lisp` option

Some plugins use set lisp? to determine if the file is Lisp or not. It would be cool if you had lisp option set just so that outside plugins may detect Clojure as Lisp. It's possible for outside plugins to hardcode Clojure as Lisp, but I don't think that's the best approach.

[Bug] incorrect indentation for curly braces with `=`

When typing, indentation is correct, but when indenting using something like gg=G, the indentation becomes incorrect. The following example is in Fennel, but the idea is the same.

Correct indentation:

{1 :gbprod/cutlass.nvim
 :opts {:cut_key :x
        :exclude [:ns :nS]
        :registers {:change :c :delete :d :select :s}}}

After gg=G:

{1 :gbprod/cutlass.nvim
:opts {:cut_key :x
:exclude [:ns :nS]
:registers {:change :c :delete :d :select :s}}}

Also see neovim/neovim#24080

Compatibility with tree-sitter

Hey friends,

The indentation system is built on the syntax highlighting to know how to interpret things like \{. If I use nvim-treesitter (which relies on this grammar) and disable nvim's syntax highlighting, indentation is completely broken.

I don't want to lose the nice indentation provided by this plugin (as there is no indentation information for Clojure in nvim-treesitter), but enabling both vimscript syntax highlighting and treesitter highlighting is bad and slow.

Any suggestions on how to handle this?

Highlight `clojure.test` macros

I import them frequently and probably everyone does. It would probably be a good idea.

I think this should work but I don't know why it doesn't work (also you use a generator and probably don't even need this):

syntax keyword clojureTestMacro deftest is
highlight link clojureTestMacro clojureMacro

Is it possible to highlight function docStrings?

Was wondering if it is possible to target the doc strings that are in a defn form separately from normal Strings?
(defn my-function "This is the doc string I am talking about. It would be great if this can be highlighted differently from regular Strings" [arg 1 arg2] ...
I probably need a syntax region, but I am lost with the syntax file format. Thanks

Fix syntax generation code for Java 11+

Currently the syntax generation code only works on Java 8 (and below) as the latest JDK versions no longer contain some classes we used for reflection.

These missing classes are:

  • java.util.regex.Pattern$CharPropertyNames
  • java.util.regex.UnicodeProp

To fix this the reflection code needs replacing as there are no straightforward replacements for these classes.

I have already done some work on building the new reflection code.

Submit changes to upstream Vim

We should consider submitting the latest changes for inclusion in Vim soon (preferably sometime before Vim 9 is released).

For this we will need to:

  1. merge all open PRs which we want included,
  2. test for regressions (I haven't found any yet),
  3. write a summary of the included changes,
  4. generate the patch (there is a comment in generate.clj on how to do this),
  5. send the patch and summary (with a mention of the maintainership change) to the Vim-dev mailing list (+ CC @guns in the email),
  6. await feedback.

NOTE: apparently it is now possible to open a pull request in the Vim GitHub repository instead of sending an email as that will automatically send the email and run the CI tests.

Open questions:

  1. Should we also submit these changes to Neovim? (Does Neovim do it the same way?)

Create sub-filetypes for EDN, boot and Leiningen files

This is a proposal/request for comments for a possible future change. No change will be made/merged without feedback or demand.


It is possible to make Clojure.vim automatically mark specific Clojure files as Clojure sub-types by using a lesser known Vim feature detailed under :h 'filetype'. This may improve configurabilty and allow other plugins to run specific code for each sub-filetype.

This can be done by changing the filetype detection code to something like this:

" ftdetect/clojure.vim
autocmd BufNewFile,BufRead *.clj,*.cljc,*.cljs setlocal filetype=clojure  " Maybe even separate out cljs?
autocmd BufNewFile,BufRead *.edn setlocal filetype=clojure.edn
autocmd BufNewFile,BufRead {build,profile}.boot setlocal filetype=clojure.boot
autocmd BufNewFile,BufRead project.clj setlocal filetype=clojure.lein

This would also make it possible to add additional syntax keywords per sub-filetype, such as highlighting defproject only in project.clj files.

There may be better ways of achieving the same goals without having to add lots of new filetypes (which may conflict with other filetypes included in Vim). If you can think of any or have any thoughts on this, please leave a comment below.

Improve indent performance

guns/vim-clojure-static#88

With 6b18b4e test script, master:

FUNCTIONS SORTED ON SELF TIME
count  total (s)   self (s)  function
29646              4.656598  <SNR>35_syn_id_name()
 1532   5.261001   0.407066  <SNR>35_match_pairs()
29028   4.712738   0.186393  <SNR>35_ignored_region()
28332   4.856748   0.155025  <SNR>35_is_paren()
30068              0.059254  <SNR>35_current_char()
  417   5.570994   0.033857  GetClojureIndent()
  417   5.439542   0.032423  <SNR>35_clojure_indent_pos()
  315   1.959061   0.012072  <SNR>35_clojure_is_method_special_case_worker()
  416   0.112460   0.006156  <SNR>35_clojure_check_for_string_worker()
  416   0.116510   0.004050  <SNR>35_check_for_string()
  581              0.003795  <SNR>35_strip_namespace_and_macro_chars()
  130              0.003790  <SNR>35_match_one()
  581              0.003502  <SNR>35_current_word()
  315   1.962500   0.003439  <SNR>35_is_method_special_case()
 1395              0.002532  <SNR>35_bracket_type()
  315              0.001042  <SNR>35_is_reader_conditional_special_case()

Because indent uses the syntax rules, #5 branch already improves this a quite bit:

FUNCTIONS SORTED ON SELF TIME
count  total (s)   self (s)  function
29646              1.478719  <SNR>35_syn_id_name()
 1532   2.199816   0.404030  <SNR>35_match_pairs()
29028   1.617763   0.185423  <SNR>35_ignored_region()
28332   1.798798   0.156209  <SNR>35_is_paren()
30068              0.059659  <SNR>35_current_char()
  417   2.391534   0.034190  GetClojureIndent()
  417   2.312287   0.032532  <SNR>35_clojure_indent_pos()
  315   0.809202   0.011783  <SNR>35_clojure_is_method_special_case_worker()
  416   0.046043   0.006287  <SNR>35_clojure_check_for_string_worker()
  130              0.004105  <SNR>35_match_one()
  581              0.004033  <SNR>35_strip_namespace_and_macro_chars()
  416   0.050047   0.004003  <SNR>35_check_for_string()
  581              0.003524  <SNR>35_current_word()
  315   0.812542   0.003340  <SNR>35_is_method_special_case()
 1395              0.002603  <SNR>35_bracket_type()
  315              0.001093  <SNR>35_is_reader_conditional_special_case()

Testing against Reagent src/reagent/impl/component.cljs.

Highlight symbols in function position

I have a custom syntax regex for highlighting symbols that are in function position in a list. I've added it to clojureTop before the built-in functions list so they can be highlighted distinctly if desired. Would y'all be interested in a PR for this?

Highlight stacked discard macros

Currently the syntax highlighting support for the discard reader macro (#_) is limited to a single form, however Clojure supports stacking them which comments out subsequent forms.

;; Correctly highlighted:
(defn foo [x]
  {:bar  (+ x 1)
   #_:biz #_(* x 2)})

;; Incorrectly highlighted:
(defn foo [x]
  {:bar (+ x 1)
   #_#_:biz (* x 2)})

It may not be possible to implement this behaviour, but is worth trying. If it isn't possible (to do efficiently) we may just disable the existing comment reader macro highlighting support by default for consistency.

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.