All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Author: suoto <andre820@gmail.com>
2 " Description: Adds support for HDL Code Checker, which wraps vcom/vlog, ghdl
3 " or xvhdl. More info on https://github.com/suoto/hdl_checker
5 call ale#Set('hdl_checker_executable', 'hdl_checker')
6 call ale#Set('hdl_checker_config_file', has('unix') ? '.hdl_checker.config' : '_hdl_checker.config')
7 call ale#Set('hdl_checker_options', '')
9 " Use this as a function so we can mock it on testing. Need to do this because
10 " test files are inside /testplugin (which refers to the ale repo), which will
11 " always have a .git folder
12 function! ale#handlers#hdl_checker#IsDotGit(path) abort
13 return ! empty(a:path) && isdirectory(a:path)
16 " Should return (in order of preference)
17 " 1. Nearest config file
18 " 2. Nearest .git directory
20 function! ale#handlers#hdl_checker#GetProjectRoot(buffer) abort
21 let l:project_root = ale#path#FindNearestFile(
23 \ ale#Var(a:buffer, 'hdl_checker_config_file'))
25 if !empty(l:project_root)
26 return fnamemodify(l:project_root, ':h')
29 " Search for .git to use as root
30 let l:project_root = ale#path#FindNearestDirectory(a:buffer, '.git')
32 if ale#handlers#hdl_checker#IsDotGit(l:project_root)
33 return fnamemodify(l:project_root, ':h:h')
39 function! ale#handlers#hdl_checker#GetExecutable(buffer) abort
40 return ale#Var(a:buffer, 'hdl_checker_executable')
43 function! ale#handlers#hdl_checker#GetCommand(buffer) abort
44 let l:command = ale#Escape(ale#handlers#hdl_checker#GetExecutable(a:buffer)) . ' --lsp'
46 " Add extra parameters only if config has been set
47 let l:options = ale#Var(a:buffer, 'hdl_checker_options')
50 let l:command = l:command . ' ' . l:options
57 function! ale#handlers#hdl_checker#GetInitOptions(buffer) abort
58 return {'project_file': ale#Var(a:buffer, 'hdl_checker_config_file')}
61 " Define the hdl_checker linter for a given filetype.
62 function! ale#handlers#hdl_checker#DefineLinter(filetype) abort
63 call ale#linter#Define(a:filetype, {
64 \ 'name': 'hdl_checker',
65 \ 'aliases': ['hdl-checker'],
67 \ 'language': a:filetype,
68 \ 'executable': function('ale#handlers#hdl_checker#GetExecutable'),
69 \ 'command': function('ale#handlers#hdl_checker#GetCommand'),
70 \ 'project_root': function('ale#handlers#hdl_checker#GetProjectRoot'),
71 \ 'initialization_options': function('ale#handlers#hdl_checker#GetInitOptions'),