Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VimScript & Plugin Notes #7

Open
coolaj86 opened this issue Aug 3, 2023 · 0 comments
Open

VimScript & Plugin Notes #7

coolaj86 opened this issue Aug 3, 2023 · 0 comments

Comments

@coolaj86
Copy link
Contributor

coolaj86 commented Aug 3, 2023

Just putting these somewhere so I don't lose them.

vimscript 101

' string
['a', 'b'] list
{ 'key': 'value' } map
" comment
\ escape previous newline+whitespace
# filepath
TitleCase function name

How to add a fixer?

DO NOT use hyphens in the file name!! ajscript_fmt.vim vs ajscript-fmt.vim

See https://github.com/dense-analysis/ale/pull/4427/files

autoload/ale/fix/registry.vim

# ale#fix#registry#Add(name, func, filetypes, desc, ...)
ale#fix#registry#Add(
\  'ajscript-fmt',
\  'ale#fixers#ajscript_fmt#Fix',
\  ['javascript', 'ajscript'],
\  'Apply AJScript format to a file.'
\)
\   'ajscript-fmt': {
\       'function': 'ale#fixers#ajscript_fmt#Fix',
\       'suggested_filetypes': ['javascript', 'ajscript'],
\       'description': 'Apply AJScript format to a file.',
\   },
    " g: global var
    " a: function argument
    " b: ?? variable
    " l: function-local variable
    " %t means current filename (says gpt)
    " :h means dirname (head)
    " :t means filename (tail)
function! ale#fixers#ajscript_fmt#GetCwd(buffer) abort
    let l:config = ale#path#FindNearestFile(a:buffer, '.ajscript.json')

    " Fall back to the directory of the buffer
    return !empty(l:config) ? fnamemodify(l:config, ':h') : '%s:h'
endfunction

LSP Server

https://www.toptal.com/javascript/language-server-protocol-tutorial

  call ale#linter#Define('filetype_here', {
  \   'name': 'any_name_you_want',
  \   'lsp': 'socket',
  \   'address': 'servername:1234',
  \   'project_root': '/path/to/root_of_project',
  \})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant