Giter Site home page Giter Site logo

Comments (5)

heavenshell avatar heavenshell commented on May 27, 2024

@berndartmueller
Hi, thank you for comment.

What do you mean about use an appropriate formatter.

Do you want to use something like *.js -> JsDoc format, *.ts -> TsDoc format?
Can you tell me little more detail?

from vim-jsdoc.

berndartmueller avatar berndartmueller commented on May 27, 2024

It would be great to have based on the current file (.js, .ts) either JsDoc or TsDoc used for formatting.

For now I set TsDoc as my default formatter, but occasionally I work on .js files and then it would be great to automatically format it with JsDoc.

from vim-jsdoc.

heavenshell avatar heavenshell commented on May 27, 2024

@berndartmueller

How about this?

Put followings to your .vimrc

function! s:jsdoc_formatter() abort
  if &filetype == 'typescript'
    let g:jsdoc_formatter = 'tsdoc'
  elseif &filetype == 'javascript'
    let g:jsdoc_formatter = 'jsdoc'
  endif                     
endfunction                 
autocmd BufWinEnter,BufNewFile *.ts,*.js call s:jsdoc_formatter()

from vim-jsdoc.

berndartmueller avatar berndartmueller commented on May 27, 2024

Awesome!

Thanks a lot @heavenshell

I extended your script slightly to have different formatter loaded too.

function! s:jsdoc_formatter() abort
  if &filetype == 'typescript'
    let g:jsdoc_formatter = 'tsdoc'
    let g:jsdoc_templates_path = '~/.vim/vim-jsdoc/ts-formatter.js'
  elseif &filetype == 'javascript'
    let g:jsdoc_formatter = 'jsdoc'
    let g:jsdoc_templates_path = '~/.vim/vim-jsdoc/js-formatter.js'
  endif
endfunction

from vim-jsdoc.

heavenshell avatar heavenshell commented on May 27, 2024

Great!

from vim-jsdoc.

Related Issues (20)

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.