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

Basic haskell support #37

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions ftplugin/haskell/sideways.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
if exists('b:sideways_definitions')
finish
endif

" \ {
" \ 'start': '\%(^\s*\|[=(]\s*\)\k\{1,} \ze\s*[^=,*/%<>+-]',
" \ 'end': '\s*\%(=\|--\)',
" \ 'delimiter': ' \+',
" \ 'brackets': ['([{"', ')]}"'],
" \ },

let b:sideways_definitions = [
\ {
\ 'start': '\k\+\s*::\s*',
\ 'end': '\s*\%(--\|$\)',
\ 'delimiter': '\s*->\s*',
\ 'brackets': ['([{"', ')]}"'],
\ },
\ {
\ 'start': '\',
\ 'end': '->',
\ 'delimiter': ' \+',
\ 'brackets': ['', ''],
\ },
\ {
\ 'start': '^\s*\k\{1,} \ze\s*[^=,*/%<>+-]',
\ 'end': '\s*\%(=\|--\)',
\ 'brackets': ['([{"', ')]}"'],
\ 'single_line': 1,
\ 'delimited_by_whitespace': 1,
\ },
\ ]
64 changes: 64 additions & 0 deletions spec/plugin/haskell_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
require 'spec_helper'

describe "haskell" do
let(:filename) { 'test.hs' }

specify "function type definition" do
set_file_contents <<-EOF
function :: X -> Y -> Integer
function x y = 13
EOF

vim.search('X')
vim.right
assert_file_contents <<-EOF
function :: Y -> X -> Integer
function x y = 13
EOF

vim.left
assert_file_contents <<-EOF
function :: X -> Y -> Integer
function x y = 13
EOF
end

specify "lambda function arguments" do
set_file_contents <<-EOF
let l = \\x y z -> 13
EOF

vim.search('x')
vim.right
assert_file_contents <<-EOF
let l = \\y x z -> 13
EOF

vim.right
assert_file_contents <<-EOF
let l = \\y z x -> 13
EOF

vim.right
assert_file_contents <<-EOF
let l = \\x z y -> 13
EOF
end

specify "function definitions" do
set_file_contents <<-EOF
add x y = x + y
EOF

vim.search('add \zsx')
vim.right
assert_file_contents <<-EOF
add y x = x + y
EOF

vim.right
assert_file_contents <<-EOF
add x y = x + y
EOF
end
end