GithubHelp home page GithubHelp logo

beyondcodebootcamp / vim-ale-hello-world Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 29 KB

A simple Hello World-style tutorial for a plugin for vim-ale

License: Mozilla Public License 2.0

Vim Script 34.60% Shell 46.09% JavaScript 19.31%

vim-ale-hello-world's Introduction

vim-ale-hello-world's People

Contributors

coolaj86 avatar

Stargazers

 avatar

vim-ale-hello-world's Issues

Add autocomplete example

It looks like vim-ale supports autocomplete.

I'd be interested to see what that could look like.

Could probably prototype with vscode-language-server (but it seems like it's wicked slow, so maybe not production?).

let g:ale_completion_enabled = 1
let g:ale_lsp_suggestions = 1
~/.vim/pack/plugins/start/ale/
    doc/ale-supported-languages-and-tools.txt
    autoload/ale/completion.vim
    autoload/ale/lsp.vim
    plugin/ale.vim

VimScript & Plugin Notes

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',
  \})

Add minimal Language Server

vscode-language-server is bloated and slow.

We could make something very simple for linting (and maybe even auto-completion) runs very quickly.

Need to test to make sure that it's not so slow when the language server is fast (maybe the bottleneck is somewhere else?).

See ./events/.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.