Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint Server #70

Closed
Wilfred opened this issue Dec 13, 2014 · 4 comments · Fixed by #194
Closed

Lint Server #70

Wilfred opened this issue Dec 13, 2014 · 4 comments · Fixed by #194

Comments

@Wilfred
Copy link

Wilfred commented Dec 13, 2014

It is now possible to use Emacs with a persistent lint process, so we need a way of running Lint.jl as a persistent process that we can query.

Does this belong in Lint.jl? If not, I'm happy to write a separate little package.

@tonyhffong
Copy link
Owner

wow, that'd be really sweet. I'm not quite sure what it entails. I'd lean towards a separate package if it requires dependency on a few non-core packages. Your judgement call.

Do let us know if you need any adjustment in to code to make that work.

@tomaskrehlik
Copy link
Contributor

I was writing a Linting plugin for Sublime and I am quite disappointed how slow it is so I was toying with the persistent process and I got it somehow working on OS X, have no idea how much this code might be relevant for other systems. Just sharing a proof of concept and that it works:
Put into Julia

using Lint

import Base.string

function string( m::LintMessage )
    s = @sprintf( "%s:%d ", m.file, m.line )
    s = s * @sprintf( "[%-15s] ", m.scope )
    arr = [ "INFO", "WARN", "ERROR", "FATAL" ]
    s = s * @sprintf( "%-5s  ", arr[ m.level+1 ] )
    ident = min( 60, length(s) )
    lines = split(m.message, "\n")
    for (i,l) in enumerate(lines)
        if i==1
            s = s * l
        else
            s = s * "\n" *  (" " ^ ident) * l
        end
    end
    return s
end

server = listen(2222)
while true
  conn = accept(server)
  @async begin
    try
      while true
        line = readline(conn)
        # println(typeof(line))
        # println(ispath(strip(line)))
        # println(strip(line))
        m = lintfile(strip(line), returnMsgs = true)
        for i in m
            write(conn, string(i))
            write(conn, "\n")
        end
      end
    catch err
      print("connection ended with error $err")
    end
  end
end

then from bash you can call nc localhost 2222 on the following prompt, you just enter the path to the file and it prints out the message.

The script is by no means fool proof.

@tomaskrehlik
Copy link
Contributor

OK, I was really frustrated so made it work, again a bit of a hack, but works for SublimeLinter. Let me know if you want to pull this.

@tonyhffong
Copy link
Owner

I'm happy to give it a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants