blob: 6c61c818d19a34ff6871bd39200a96682970c3ee [file] [log] [blame]
Amelia Clarke35dfe582024-05-24 08:05:00 +02001" Vim filetype plugin.
2" Language: Hare
3" Maintainer: Amelia Clarke <selene@perilune.dev>
Konfekt7c3f9af2024-10-05 17:26:46 +02004" Last Updated: 2024 Oct 04
Amelia Clarke35dfe582024-05-24 08:05:00 +02005" 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" Formatting settings.
dkearnsf937ab32023-08-29 05:32:27 +100016setlocal comments=://
17setlocal commentstring=//\ %s
Amelia Clarke35dfe582024-05-24 08:05:00 +020018setlocal formatlistpat=^\ \\?-\
19setlocal formatoptions+=croqnlj/ formatoptions-=t
20
21" Search for Hare modules.
22setlocal include=^\\s*use\\>
23setlocal includeexpr=hare#FindModule(v:fname)
24setlocal isfname+=:
dkearnsf937ab32023-08-29 05:32:27 +100025setlocal suffixesadd=.ha
26
Amelia Clarke35dfe582024-05-24 08:05:00 +020027" Add HAREPATH to the default search paths.
28setlocal path-=/usr/include,,
29let &l:path .= ',' .. hare#GetPath() .. ',,'
dkearnsf937ab32023-08-29 05:32:27 +100030
Amelia Clarke35dfe582024-05-24 08:05:00 +020031let b:undo_ftplugin = 'setl cms< com< flp< fo< inc< inex< isf< pa< sua< mp<'
32
33" Follow the Hare style guide by default.
34if get(g:, 'hare_recommended_style', 1)
dkearnsf937ab32023-08-29 05:32:27 +100035 setlocal noexpandtab
Amelia Clarke35dfe582024-05-24 08:05:00 +020036 setlocal shiftwidth=0
dkearnsf937ab32023-08-29 05:32:27 +100037 setlocal softtabstop=0
38 setlocal tabstop=8
39 setlocal textwidth=80
Amelia Clarke35dfe582024-05-24 08:05:00 +020040 let b:undo_ftplugin .= ' et< sts< sw< ts< tw<'
dkearnsf937ab32023-08-29 05:32:27 +100041endif
Bram Moolenaar9fbdbb82022-09-27 17:30:34 +010042
Amelia Clarke35dfe582024-05-24 08:05:00 +020043augroup hare.vim
44 autocmd!
dkearnsf937ab32023-08-29 05:32:27 +100045
Amelia Clarke35dfe582024-05-24 08:05:00 +020046 " Highlight whitespace errors by default.
47 if get(g:, 'hare_space_error', 1)
48 autocmd InsertEnter * hi link hareSpaceError NONE
49 autocmd InsertLeave * hi link hareSpaceError Error
50 endif
51augroup END
52
Konfekt7c3f9af2024-10-05 17:26:46 +020053if !exists('current_compiler')
54 let b:undo_ftplugin .= "| compiler make"
55 compiler hare
56endif
57
Amelia Clarke35dfe582024-05-24 08:05:00 +020058let &cpo = s:cpo_save
59unlet s:cpo_save
60
61" vim: et sts=2 sw=2 ts=8