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

Indent using spaces instead of tabs #76

Open
hank-der-hafenarbeiter opened this issue Nov 26, 2020 · 8 comments
Open

Indent using spaces instead of tabs #76

hank-der-hafenarbeiter opened this issue Nov 26, 2020 · 8 comments

Comments

@hank-der-hafenarbeiter
Copy link

Hey everyone,

I don't know if this is an issue particular to my neovim setup but my editor indents using tabs and these are not legal characters in purescript. So purescript-vim should probably make sure that tabs aren't used for indentation. I mostly c+p my vimrc/init.vim together so I'm not sure what the best way to implement this is, but it should probably just say:

" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
" On pressing tab, insert 4 spaces
set expandtab

Somewhere

@nilp0inter
Copy link

I have the exact same issue using Vim 8. Is there any workaround?

@hank-der-hafenarbeiter
Copy link
Author

Well, my workaround is learning functional programming using haskell instead. For me it was about learning functional programming and I got haskell to work. I'll probably come back to this later. So for now: No, haven't found a workaround.

@mkohlhaas
Copy link
Contributor

mkohlhaas commented Dec 22, 2021

Had the same issue. I use a Lua init file and it works nicely. Lua has its own namespace. You should try something like this:

local set = vim.opt    -- acts like the :set command in vimscript; set global, window and buffer settings
set.shiftwidth = 2     -- set shift width to 4 spaces.
set.tabstop    = 2     -- set tab width to 4 columns.
set.expandtab  = true  -- Use space characters instead of tabs.

@toastal
Copy link
Collaborator

toastal commented Nov 24, 2022

Tabs are great! But yes, the PureScript compiler doesn't support it... yet.

EditorConfig: https://editorconfig.org/
purescript-tidy: https://github.com/natefaubion/purescript-tidy

This are two great options for your projects to help as well. EditorConfig will make sure your whole team's editors are using the same white space across projects. Tidy will make sure your PureScript code is formatted similarly across the project and team--including configurable indentation. With the tab support being an open discussion and the popularity of Tidy in the community allowing users to configure the number of spaces, I don't think it's in the best interest for the Vim project here to be dictating these settings on users, and instead users can differ to other tools like the ones mentioned or changing their local vimrc.

@FredTheDino
Copy link

Maybe it would be a good idea to enable just expandtab in the purescript.vim config? since the current situation is that tabs is not allowed in purescript, That would still allow users to use what ever shiftwidth and tabstop they like. It's particularly frustrating if users switch to Haskell because of this.

@toastal
Copy link
Collaborator

toastal commented Dec 5, 2022

Agreed that we should not enforce the shiftwidth and tabstop given tools like purescript-tidy allow users to configure this value. With the tab support issue having interest and being unresolved (with a community member saying they were going to investigate it), I think that this may be a bit hasty. I will double check with that member.

@FredTheDino is there an issue with setting up EditorConfig + editorconfig-vim while I get some confirmations?

@FredTheDino
Copy link

I haven't used editorconfig in the purescript projects I'm working on - it looks to work. I lean heavily on the formatter. I was mostly trying to be solve the problem practically.

I have no problems with NeoVim 0.8.1 atleast.

@klarkc
Copy link

klarkc commented Jan 11, 2023

Workaround for vim:

"{{ ~/.vimrc
function! PurescriptIndent()
  setlocal expandtab
  setlocal shiftwidth=2
  setlocal tabstop=2
endfunction

au BufRead,BufNewFile *.purs call PurescriptIndent()

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

No branches or pull requests

6 participants