Giter Club home page Giter Club logo

Comments (36)

Olical avatar Olical commented on May 14, 2024 4

Here it is working in the HUD 🎉

image

from conjure.

daveyarwood avatar daveyarwood commented on May 14, 2024 2

A built-in highlighting module sounds awesome! I think you would only need to support the ANSI color codes, which would simplify things.

from conjure.

Olical avatar Olical commented on May 14, 2024 1

I mean the luajit that is literally compiled into Neovim, give :lua print(10 + 10) a go, that's what that colorizer runs on I think? It doesn't require any Lua interpreter installed on your system. I run it in a tiny Arch Docker container for my tests in CircleCI, there's no luajit installed there.

from conjure.

daveyarwood avatar daveyarwood commented on May 14, 2024 1

@Olical I was able to get both the Conjure log buffer and HUD to colorize automatically with this little autocmd:

  " Automatically enable AnsiEsc (interpret ANSI escape codes) for the Conjure
  " log buffer.
  autocmd BufEnter conjure-log-* AnsiEsc

I'm really digging this!

from conjure.

Olical avatar Olical commented on May 14, 2024 1

I'm going to finally close this since I think we've got a solution even if it's not the best solution. Being able to turn the ANSI code filtering on or off + a solution for merging ANSI code concealing and syntax into your current syntax were the main hurdles.

I wrote up this wiki page to capture some of the information from here and give us something to link to in the future.

Closing! (unless people still have major gripes of course!)

from conjure.

m00qek avatar m00qek commented on May 14, 2024 1

Hey everyone, sorry for resurrecting this issue but this weekend I put some thought on this and came up with https://github.com/m00qek/baleia.nvim
Seems to work here in my setup, it is very experimental but you may want to give it a try.

from conjure.

m00qek avatar m00qek commented on May 14, 2024 1

@daveyarwood could you please open an issue there? Strange, baleia.lua does not have 222 lines 😬

from conjure.

Olical avatar Olical commented on May 14, 2024

Hello, I was pointed to conjure the other day and am really excited about the prospects of having a nvim clojure plugin mostly written in clojure itself, so really nice work on this!

You're more than welcome and I'm glad you're excited about the idea! I hope it ends up being a good tool you enjoy using 😄

I'm open to somehow working around ANSI codes (not fully sure on how yet 🤔) but I'm confused as to how you actually caused some? Like if I cause errors I never see any colour codes... is it a specific library that's doing this? Maybe they just need stripping out for now... for a start?

from conjure.

philomates avatar philomates commented on May 14, 2024

I think that for stacktraces you don't see ansi codes because the actual data structure is printed and hence normal vim syntax highlighting is applied to it.
In my case I'm using matcher-combinators, which is a testing lib that uses color to help signal mismatches between expected and actual data. You can turn off the ANSI code output in the library itself, but that makes reading test failures a little more difficult.

from conjure.

Olical avatar Olical commented on May 14, 2024

https://github.com/norcalli/nvim-terminal.lua 👀

Haven't forgotten about this issue, still considering it occasionally.

from conjure.

daveyarwood avatar daveyarwood commented on May 14, 2024

We have an integration testing project at Adzerk that prints to stdout with ANSI color codes. I've been itching to see if I could get colors working in the Conjure log buffer, so I gave norcalli/nvim-terminal.lua a try. It works, sort of!

2019-11-11-154715_1134x482_scrot

The downside is that you activate it by setting filetype to terminal, which overrides the clojure filetype of the Conjure log buffer and removes Clojure syntax highlighting as a side effect. Clojure filetype functionality otherwise seems to be intact, interestingly enough; parinfer and vim-sexp features were still working.

from conjure.

daveyarwood avatar daveyarwood commented on May 14, 2024

As an additional data point, I tried chrisbra/Colorizer, and it works (without changing the filetype, which is an improvement!), except that it doesn't interpret the "bold" ANSI codes correctly (compare with the screenshot above)

2019-11-11-160233_1105x259_scrot

from conjure.

daveyarwood avatar daveyarwood commented on May 14, 2024

chrisbra/Colorizer is actually turning out to be sort of flaky; I'm not sure that I would 100% recommend it for Conjure purposes at this point.

What I'm seeing is that it will randomly flip back and forth between rendering colors and not rendering colors in the Conjure log buffer, e.g. when I give focus or don't give focus to the Conjure log buffer.

from conjure.

Olical avatar Olical commented on May 14, 2024

Had a look at this? https://github.com/norcalli/nvim-colorizer.lua

It might not do term codes just yet, but a fork of it embedded into the new Lua based Conjure could solve this issue really easily 🤔

from conjure.

Olical avatar Olical commented on May 14, 2024

norcalli/nvim-colorizer.lua#31 👀 exciting. I really like this plugin, I use it all the time anyway so it could be good to build a subset into Conjure's log or just recommend it as a pairing once it has term code support?

It's one of the plugins that got me really interested in full Lua plugin development for Neovim actually!

from conjure.

daveyarwood avatar daveyarwood commented on May 14, 2024

That plugin looks super awesome, but unfortunately, I can't use it because (to my understanding) Ubuntu 16.04 doesn't package Luajit or something. I'm not too familiar with the Lua ecosystem. Perhaps there is a way to install Luajit? The last time I went down this path, it was not a good experience, so I think I'm inclined to just wait for my distro to catch up.

from conjure.

daveyarwood avatar daveyarwood commented on May 14, 2024

Relevant: norcalli/nvim-colorizer.lua#30

from conjure.

Olical avatar Olical commented on May 14, 2024

Neovim has Lua support built in :D that's what the new Conjure runs on top of. Try :lua

from conjure.

daveyarwood avatar daveyarwood commented on May 14, 2024

The issue is about Luajit support, which I think might depend on your OS's Lua package. I apparently don't have Luajit support. I'm not sure if I'm doing it right or wrong here, but:

$ lua
Lua 5.3.4  Copyright (C) 1994-2017 Lua.org, PUC-Rio
> require 'ffi'
stdin:1: module 'ffi' not found:
        no field package.preload['ffi']
        no file '/home/dave/.lenv/current/luarocks/share/ffi.lua'
        no file '/home/dave/.lenv/current/luarocks/share/ffi/init.lua'
        no file '/usr/local/share/lua/5.3/ffi.lua'
        no file '/usr/local/share/lua/5.3/ffi/init.lua'
        no file '/usr/local/lib/lua/5.3/ffi.lua'
        no file '/usr/local/lib/lua/5.3/ffi/init.lua'
        no file './ffi.lua'
        no file './ffi/init.lua'
        no file '/home/dave/.lenv/current/luarocks/lib/ffi.so'
        no file '/usr/local/lib/lua/5.3/ffi.so'
        no file '/usr/local/lib/lua/5.3/loadall.so'
        no file './ffi.so'
stack traceback:
        [C]: in function 'require'
        stdin:1: in main chunk
        [C]: in ?

from conjure.

daveyarwood avatar daveyarwood commented on May 14, 2024

It looks like the last time I was trying to get this to work, I ended up installing lenv to try and install a different version of Lua, which may or may not have worked out.

from conjure.

Olical avatar Olical commented on May 14, 2024

Or are you saying you tried :lua in Neovim and it exploded? If so, that's bad news for my plans 😬

from conjure.

Olical avatar Olical commented on May 14, 2024

Oh I see! That lib needs ffi which requires luajit to be installed. I don't think Conjure's rewrite needs anything outside of plain built in lua so hopefully it'll be okay!

from conjure.

daveyarwood avatar daveyarwood commented on May 14, 2024

:lua print(10 + 10) works and returns 20.

:lua require 'ffi' throws this error:

E5108: Error executing lua [string ":lua"]:1: module 'ffi' not found:
        no field package.preload['ffi']
        no file '/home/dave/.config/nvim/lua/ffi.lua'
        no file '/home/dave/.config/nvim/lua/ffi/init.lua'
... many more lines where it's saying it couldn't find either of those two files in each of my plugin directories ...

I'd say if you don't use anything from Luajit, you're probably fine.

from conjure.

Olical avatar Olical commented on May 14, 2024

from conjure.

Olical avatar Olical commented on May 14, 2024

So I was just having a look into this and it's definitely harder than I first though, it won't be a quick win since it'll require a LOT of code to handle all of the cases. I'm almost certain I'll miss some and we'll end up with some working and some not. I did stumble across AnsiEsc though which looks amazing, it's implemented exactly how I was planning on doing it! The main problem is that it swaps the highlighting away from whatever you're currently on.

I've been trying to hack it to get it to apply on top of your current colour scheme but I've made no progress yet (Olical/AnsiEsc). Instead I've added the log.strip-ansi-escape-sequences-line-limit option which defaults to 100 lines.

It'll strip ANSI escape sequences from ALL log content less than 100 lines in length, this is so that if you accidentally dump a 100k line output into your log it won't have a series of regex find and replaces run on each line, which should keep it semi-fast. You can turn this off and preserve the codes by setting it to 0.

from conjure.

Olical avatar Olical commented on May 14, 2024

Okay, my fork of AnsiEsc (Olical/AnsiEsc) actually works to some extent now. It's a big hack, but it overlays the ANSI escape syntax over whatever you're currently using, it worked really well with Clojure! I even got it to work with Janet although that causes some weirdness with the return value highlighting.

So use :ConjureConfig log.strip-ansi-escape-sequences-line-limit 0 to disable the stripping and grab my fork, then run :AnsiEsc in the log buffer to enable it. Not sure how I could enable that automatically, I think that'll require my autocmd framework, until then you'll have to do it manually but I think that's mostly okay.

from conjure.

m00qek avatar m00qek commented on May 14, 2024

I think it can be considered stable now https://github.com/m00qek/baleia.nvim#with-conjure

from conjure.

daveyarwood avatar daveyarwood commented on May 14, 2024

@m00qek I gave those instructions a try and restarted Neovim, but ran into this error:

E5108: Error executing lua /home/dave/.vim/bundle/baleia.nvim/lua/baleia.lua:222: Expected lua string
Error executing vim.schedule lua callback: /home/dave/.vim/bundle/conjure/lua/conjure/buffer.lua:98: Vim(call):E718: Funcref required

from conjure.

daveyarwood avatar daveyarwood commented on May 14, 2024

I opened that file on my machine, and it has 238 lines!

from conjure.

daveyarwood avatar daveyarwood commented on May 14, 2024

I wonder if I might have an old version cached, or something.

from conjure.

daveyarwood avatar daveyarwood commented on May 14, 2024

Aha! That's totally it. I did rm -rf ~/.vim/bundle/baleia.nvim and then reinstalled it and now that file has 83 lines.

from conjure.

daveyarwood avatar daveyarwood commented on May 14, 2024

2021-09-20-122834_705x100_scrot
2021-09-20-122844_653x129_scrot

It works, both in the HUD and the Conjure log buffer. Awesome work, @m00qek !! 🎉 💯

from conjure.

daveyarwood avatar daveyarwood commented on May 14, 2024

One thing worth noting is that bold text isn't being displayed as bold. I'll open an issue for that.

from conjure.

daveyarwood avatar daveyarwood commented on May 14, 2024

2021-09-20-132045_937x257_scrot

Bold is working now too. I'm stoked about this! 💯

from conjure.

m00qek avatar m00qek commented on May 14, 2024

@daveyarwood is it performing well for you? As it needs to watch for changes in the log buffer and then rewrite the changed lines I wonder if it will perform badly in some setups. It would be nice if it was possible to pass a custom vim.api.nvim_buf_set_lines to conjure so it would not be necessary to watch and rewrite lines

from conjure.

daveyarwood avatar daveyarwood commented on May 14, 2024

I haven't used it much yet, but so far so good! I'll post back here if I notice any performance issues.

from conjure.

Related Issues (20)

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.