blob: 422bb7b4e8acafcc20448c938b7aa1783913767b [file] [log] [blame]
Amelia Clarke35dfe582024-05-24 08:05:00 +02001" Vim filetype plugin.
2" Language: Hare
3" Maintainer: Amelia Clarke <selene@perilune.dev>
4" Last Updated: 2024-05-10
5" Upstream: https://git.sr.ht/~sircmpwn/hare.vim
Bram Moolenaar9fbdbb82022-09-27 17:30:34 +01006
Bram Moolenaar9fbdbb82022-09-27 17:30:34 +01007if exists('b:did_ftplugin')
8 finish
9endif
Bram Moolenaar9fbdbb82022-09-27 17:30:34 +010010let b:did_ftplugin = 1
11
Amelia Clarke35dfe582024-05-24 08:05:00 +020012let s:cpo_save = &cpo
13set cpo&vim
Bram Moolenaar9fbdbb82022-09-27 17:30:34 +010014
Amelia Clarke35dfe582024-05-24 08:05:00 +020015" Set the default compiler.
16compiler hare
17
18" Formatting settings.
dkearnsf937ab32023-08-29 05:32:27 +100019setlocal comments=://
20setlocal commentstring=//\ %s
Amelia Clarke35dfe582024-05-24 08:05:00 +020021setlocal formatlistpat=^\ \\?-\
22setlocal formatoptions+=croqnlj/ formatoptions-=t
23
24" Search for Hare modules.
25setlocal include=^\\s*use\\>
26setlocal includeexpr=hare#FindModule(v:fname)
27setlocal isfname+=:
dkearnsf937ab32023-08-29 05:32:27 +100028setlocal suffixesadd=.ha
29
Amelia Clarke35dfe582024-05-24 08:05:00 +020030" Add HAREPATH to the default search paths.
31setlocal path-=/usr/include,,
32let &l:path .= ',' .. hare#GetPath() .. ',,'
dkearnsf937ab32023-08-29 05:32:27 +100033
Amelia Clarke35dfe582024-05-24 08:05:00 +020034let b:undo_ftplugin = 'setl cms< com< flp< fo< inc< inex< isf< pa< sua< mp<'
35
36" Follow the Hare style guide by default.
37if get(g:, 'hare_recommended_style', 1)
dkearnsf937ab32023-08-29 05:32:27 +100038 setlocal noexpandtab
Amelia Clarke35dfe582024-05-24 08:05:00 +020039 setlocal shiftwidth=0
dkearnsf937ab32023-08-29 05:32:27 +100040 setlocal softtabstop=0
41 setlocal tabstop=8
42 setlocal textwidth=80
Amelia Clarke35dfe582024-05-24 08:05:00 +020043 let b:undo_ftplugin .= ' et< sts< sw< ts< tw<'
dkearnsf937ab32023-08-29 05:32:27 +100044endif
Bram Moolenaar9fbdbb82022-09-27 17:30:34 +010045
Amelia Clarke35dfe582024-05-24 08:05:00 +020046augroup hare.vim
47 autocmd!
dkearnsf937ab32023-08-29 05:32:27 +100048
Amelia Clarke35dfe582024-05-24 08:05:00 +020049 " Highlight whitespace errors by default.
50 if get(g:, 'hare_space_error', 1)
51 autocmd InsertEnter * hi link hareSpaceError NONE
52 autocmd InsertLeave * hi link hareSpaceError Error
53 endif
54augroup END
55
56let &cpo = s:cpo_save
57unlet s:cpo_save
58
59" vim: et sts=2 sw=2 ts=8