mpickering / hlint-refactor-mode

Emacs bindings for hlint's --refactor option
MIT License
27 stars 5 forks source link

Spacemacs #6

Open fatlazycat opened 8 years ago

fatlazycat commented 8 years ago

Hi, doesn't appear to work within Spacemacs.

I assume something todo with using evil-mode ?

Thanks

mpickering commented 8 years ago

I'm sorry but I have not used spacemacs a lot. When I did use it though, I think that I was able to use the same emacs keybindings (for coq for example).

fatlazycat commented 8 years ago

Sorry should have been clearer, i can invoke either refactor fn but there is no change applied to the buffer.

Will try and take a look at some point

mpickering commented 8 years ago

Does it work using hlint directly? (hlint --refactor) ?

fatlazycat commented 8 years ago

Yep thats fine, that outputs a changed file to stdout

cocreature commented 8 years ago

@fatlazycat Could you provide an example file that you tried, the function you called (and also how you called it) and the point your cursor was on?

I’ve never used spacemacs, but I'll try taking a look at it if you provide an example.

fatlazycat commented 8 years ago

Simple example, https://github.com/fatlazycat/eventjournal/blob/master/test/JournalFileTests.hs

Cursor on the d of do. In the gutter I see 'mark set' after a C-c , r

Thanks

mpickering commented 8 years ago

What about if you have the cursor over the o?

On Sun, Nov 29, 2015 at 2:31 PM, Graham Berks notifications@github.com wrote:

Simple example, https://github.com/fatlazycat/eventjournal/blob/master/test/JournalFileTests.hs

Cursor on the d of do. In the gutter I see 'mark set' after a C-c , r

Thanks

— Reply to this email directly or view it on GitHub https://github.com/mpickering/hlint-refactor-mode/issues/6#issuecomment-160419413 .

fatlazycat commented 8 years ago

No difference

On 29 November 2015 at 18:51:25, Matthew Pickering (notifications@github.com) wrote:

What about if you have the cursor over the o?

On Sun, Nov 29, 2015 at 2:31 PM, Graham Berks notifications@github.com wrote:

Simple example, https://github.com/fatlazycat/eventjournal/blob/master/test/JournalFileTests.hs

Cursor on the d of do. In the gutter I see 'mark set' after a C-c , r

Thanks

— Reply to this email directly or view it on GitHub https://github.com/mpickering/hlint-refactor-mode/issues/6#issuecomment-160419413 .

— Reply to this email directly or view it on GitHub.

cocreature commented 8 years ago

Alright, I've managed to install spacemacs, but sadly I can’t reproduce this. If my d,o or anywhere inside the do block it works. Also it doesn’t matter whether I’m in insert mode or in whatever the mode after you press escape is called.

Here’s a list of things that could cause problems

fatlazycat commented 8 years ago

Hmm, odd.

Updated to latest via melpa.

Both in path.

Same problem if run manually.

I don’t set any hlint options.

Nothing in messages.

Started with a clean install and still get the same error.

Perhaps OSX or the version of emacs I’m using railwaycat/emacsmacport/emacs-mac: stable emacs-24.5-z-mac-5.13

aijony commented 7 years ago

This issue is old, but I think I found a fix (at least for me).

I had this:

(setenv "PATH" (concat  "~/.local/bin:" (getenv "PATH")))
(add-to-list 'exec-path "~/.local/bin/")

and I changed it to:

(setenv "PATH" (concat (file-truename "~/.local/bin:") (getenv "PATH")))
(add-to-list 'exec-path "~/.local/bin/")

I guess it needed to be an absolue file path :/

tonyday567 commented 7 years ago

I use spacemacs and hlint-refactor-refactor-buffer works most of time. Works is not really the right term - it is a thing of joy not to have to manually fix redundant brackets and bracket moving to avoid $. Except when the file seems to be too large, or there are many hlints, in which case it doesn't make any changes and the file flashes an unpleasant yellow hue. I then figure its hlint telling me to reduce complexity levels.

georgewsinger commented 5 years ago

I'm also having the same problem 2 years later :scream:

I have verified that hlint is installed and that hlint --refactor [filename.hs] outputs to console (though it seems to just spit out my actual file, and not with any of the suggested fixes). I have hlint errors showing up in spacemacs:

(See the blue underlines).

However, when I run, i.e., hlint-refactor-at-point (with the cursor at one of the data's above), then the error isn't fixed (i.e., the data isn't converted to a newtype). Nothing happens. When I enable toggle-debug-on-error I don't get an error/backtrace. Nothing shows up in *Messages*. My exec-path is also configured correctly.

One thing that may be of issue is that I don't have a program called refact, but I do have a program called refactor (I think this is the binary associated with apply-refact).

NOTE: In case it matters I wasn't able to get hlint errors to show up in spacemacs without inserting this into my .spacemacs:

;; https://stackoverflow.com/questions/40400547/using-hlint-with-intero-on-emacs
(with-eval-after-load 'intero
  (flycheck-add-next-checker 'intero '(warning . haskell-hlint))
)

EDIT: After restarting emacs, hlint refactoring seems to work on everything but do blocks, where hlint seems to get tripped up about where the actual error is located (telling me its on a do block but in fact its somewhere else on the line).

mpickering commented 5 years ago

If I remember right the "data to newtype" hint is not one which is fixed by the plugin. Perhaps try another hint?

listx commented 5 years ago

I solved this by installing the refactor binary with

stack install apply-refact