5d84305a3c11f467b1ef94b2a7f7b821d54acd23 — Amelia Clarke 1 year, 2 months ago 30df75b
ftplugin: conform to Vim style

This commit makes a few minor adjustments to the Hare filetype plugin to
conform to the style used by Vim itself. Specifically, the preferred
indentation and textwidth settings for Hare are now gated behind
'g:hare_recommended_style' but are still set by default. Additionally,
the required 'b:undo_ftplugin' has been added.

Besides minor adjustments to formatting and the addition of 'comments'
and 'suffixesadd', '/' has been added to 'formatoptions', meaning that
comments are only continued by 'o' and 'O' if the comment is at the
beginning of the line. When the comment is at the end of a statement,
comments will not be continued:

	defer free(buf); // This comment will not be continued.

Signed-off-by: Amelia Clarke <me@rsaihe.dev>
1 files changed, 18 insertions(+), 12 deletions(-)

M ftplugin/hare.vim
M ftplugin/hare.vim => ftplugin/hare.vim +18 -12
@@ 2,26 2,32 @@
" Language: Hare
" Maintainer: Amelia Clarke <me@rsaihe.dev>
" Previous Maintainer: Drew DeVault <sir@cmpwn.com>
" Last Updated: 2022-09-21
" Last Updated: 2022-09-28

" Only do this when not done yet for this buffer
if exists('b:did_ftplugin')

" Don't load another plugin for this buffer
let b:did_ftplugin = 1

setlocal noexpandtab
setlocal tabstop=8
setlocal shiftwidth=0
setlocal softtabstop=0
setlocal textwidth=80
" Formatting settings.
setlocal formatoptions-=t formatoptions+=croql/

" Miscellaneous.
setlocal comments=://
setlocal commentstring=//\ %s
setlocal suffixesadd=.ha

" Set 'formatoptions' to break comment lines but not other lines,
" and insert the comment leader when hitting <CR> or using "o".
setlocal fo-=t fo+=croql
" Hare recommended style.
if get(g:, "hare_recommended_style", 1)
  setlocal noexpandtab
  setlocal shiftwidth=8
  setlocal softtabstop=0
  setlocal tabstop=8
  setlocal textwidth=80

compiler hare

let b:undo_ftplugin = "setl cms< com< et< fo< sts< sua< sw< ts< tw<"

" vim: tabstop=2 shiftwidth=2 expandtab