and also because the commands to the terminal take so long to type
Vim has a folder located in the Home folder. It starts with a dot "."
because it is hidden.
If you have Vim installed and this folder isn't there you'll want to create ".vim"
The same goes for these non-hidden folders that go inside it:
The naming convention of Vim files is "Language.vim"
As an example, Vim looks for Python.vim in the ftplugin folder for Python plugins and syntax folder for Syntax files.
If Vim didn't recognize Python files by default, we would also have a Python.vim file in the ftdetect folder.
Because Vim doesn't recgonize Vala we must fix this by putting a Vala.vim in the ftdetect folder!
Vala.vim for ftdetect folder.
- Code: Select all
"Detects Vala file type.
"Necessary for everything to work properly.
au BufNewFile,BufRead *.vala set filetype=vala
Now that Vim can recognize the Vala filetype it will look for any plugins it might have upon startup.
Vala.vim for ftplugin folder.
- Code: Select all
" Plugin for working on Vala files.
" See :help usr_40.2 in Vim for info on User Defined commands.
" User defined commands/functions must start with an Uppercase letter
" and are case sensitive when typed.
" These commands can be auto-completed by hitting the tab key.
" Typing gtk + <Tab> will autofill GtkValac.
" % represents the current filename. %< removes the file extension.
" The exclamation mark (!) lets us issue a command to BASH.
" If you have a file open in Vim called Test.vala
" the command :!echo % will print the filename to the terminal.
" The combination of exec() and shellescape() lets us use Vim
" variables in the command we issue to the terminal.
" Cobbled together by Corvalis
" Create Vala library from the current file.
" Creates a C, Header, and VAPI file.
command CreateVlib :call CreateVlib()
!valac %<.vala -C -H %<.h --library %< --basedir ./
" Compile Vala library from current file.
" Creates a SO file.
command CompileVlib :call CompileVlib()
!gcc %<.c --shared -fPIC -o lib%<.so $(pkg-config --cflags --libs gobject-2.0)
" Remove C, Header, and VAPI files used to compile library.
command SweepVlib :call SweepVlib()
!rm %<.c %<.h %<.vapi
" Link Vala file to a Vlib. Takes 1 argument after command is entered.
" For instance, :LinkVlib theLibrary
command -nargs=1 LinkVlib call LinkVlib(<f-args>)
exec("!valac -X -I. -X -L. -X -l" . shellescape(a:Library) . " %<.vala -o %< " . shellescape(a:Library) . ".vapi --basedir ./")
" Compile Vala file with the Gtk+-3 package.
command GtkValac call GtkValac()
!valac --pkg gtk+-3.0 %
" Run the current executable Vala file, y'know, if it exists.
" NOTE: This assumes that the executable doesn't have a file extension
" but you can tweak it however you like.
command RunVala call RunVala()
It took some searching, but I found that the Gnome wiki has a page where you can download a Vala syntax file, which naturally goes in your syntax folder ^_^