Giter Site home page Giter Site logo

vim-fish's Introduction

vim-fish

This is an addon for Vim providing support for editing fish scripts.

Features aplenty

  • Syntax highlighting and filetype detection, of course.
  • Automatic indentation based on keywords for control structures.
  • Automatic folds for everything that end terminates in fish.
  • Code formatting with fish_indent using the gq operator.
  • Jumping to file in fish's function path that defines the function under the cursor using the gf command.
  • Searching for definitions including sourced files using commands like [i.
  • Keyword lookup that includes pages for fish builtins using the K command.
  • Completions from fish using the ^X^O command.
  • Syntax checking with quickfix using the :make command.
  • Improved funced experience using commands like S to instantly start typing commands in the function body.
  • Mimics funced when manually creating new functions.
  • Automatic formatting of comments.

For everything above to work you need to have fish installed in $PATH and some Vim features turned on. First, tell Vim to use the syntax and filetype functionality, normally in your ~/.vimrc:

syntax enable
filetype plugin indent on

Next, set some options for the fish filetype. You can do this either by prefixing each line with autocmd FileType fish, or by putting them in your own ~/.vim/ftplugin/fish.vim file:

" Set up :make to use fish for syntax checking.
compiler fish

" Set this to have long lines wrap inside comments.
setlocal textwidth=79

" Enable folding of block structures in fish.
setlocal foldmethod=expr

To make the folds more pleasant to work with you might also want to tweak settings like foldlevelstart and foldminlines, which you could do either globally in your ~/.vimrc or locally as described above.

A team player

vim-fish ships with:

But you don't have to install any of those to use this addon.

Teach a Vim to fish…

Vim needs a more POSIX compatible shell than fish for certain functionality to work, such as :%!, compressed help pages and many third-party addons. If you use fish as your login shell or launch Vim from fish, you need to set shell to something else in your ~/.vimrc, for example:

if &shell =~# 'fish$'
    set shell=sh
endif

Best do it somewhere at the top, before any addon code is loaded and executed.

Note that this also affects what :sh[ell] launches, so if you care about that you might want to set it to your second best shell instead. If you use Vim in the terminal you could also train yourself to use :st[op] or CTRL-Z instead and then fg in fish to get back to Vim.

vim-fish's People

Contributors

andersonba avatar dag avatar euclio avatar jsatk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vim-fish's Issues

Omni completion

Hooking into fish's completions would be really cool, but it would be a good start to complete functions, builtins and commands.

functions -a
builtin -n
for path in $PATH
    for bin in $path/*
        if test -x $bin
            basename $bin
        end
    end
end

Unable to create temp dir automatically

I get this error when startup.

"apt.show.url.fish" 3L, 162C^[[2;2R
Error detected while processing /home/alsan/.vim/bundle/vim-fish/ftplugin/fish.vim:
line 22:
E484: Can't open file /tmp/vK01IM9/0
Press ENTER or type command to continue

Indentation is broken

When I add an if statement, and press <Enter>, the end keyword is added. So far so good. However, if the if statement is indented already (or nested), i.e.: The i of the if and the e of end is not in column 0, and if I indent the selection with = (in normal mode using ==, or in visual mode), then the indentation completely breaks.

The breakage gets worse every time a block of code is indented, as shown in the screenshots.

macvim

macvim

macvim

macvim

Folding with syntax or foldexpr

It would be nice to have support for foldmethod=syntax or foldmethod=expr. The latter is likely faster and lets the syntax file stay clean. At a minimum function should be folded, but anything that end terminates could be considered for folding.

Completion is broken

Sometimes, when I edit fish files, I get this error many times:

Error detected while processing function fish#Complete:
line    8:
E484: Can't open file /tmp/vCliDT0/13
Press ENTER or type command to continue

What I did:

vim /tmp/test.fish
iif test -e "/ca

Then this error occurs after every character I type.

I also have vim-mucomplete installed. So vim tries to autocomplete.

"Invalid range" plugin error when opening fish file

when opening a fish file I get:

Error detected while processing /Users/miki725/.vim/plugged/vim-fish/ftplugin/fish.vim:
line   23:
E16: Invalid range: ----w

not sure how to debug this further. any ideas?

➜ nvim --version
NVIM v0.3.5
➜ vim --version
VIM - Vi IMproved 8.1 (2018 May 18, compiled May 20 2019 05:21:28)

Improve portability

It might be useful to be able to use vim-fish with the tiny and small Vim builds; we should check for the relevant features with has() guards. Similarly, it could be useful to not require the latest version of Vim and at least support whatever old version is packaged for stable Linux distributions like Debian and Red Hat. This would mean fixing issues like #13.

It's debatable whether we should support running Vim in compatible mode, which would mean things like adding &cpo resets to every file.

Broken syntax of quoted strings

If I write even number of \ right before quotes, it will show as if I wanted to escape that quote

Minimal example:

'\\' ...

Move usage notes from README to help file

This means creating a file doc/fish.txt or possibly doc/ft-fish.txt that includes helptags like ft-fish{,-syntax,-indent,-plugin,-omni} etc. The README would then refer to these for post-installation setup.

syntastic checker doesn't work with current syntastic

When I save a file with current syntastic and vim-fish enabled, I get the following error:

Unknown Function: syntastic#makeprg#build
Invalid Expression: syntastic#makeprg#build({'exe': 'fish','args': '--no-execute','subchecker': 'fish'})

Maybe their plugin API changed?

Startup of vim-fish is insanely slow

I've been loving using fish, but I've found that the startup time of this plugin is super slow, upwards of 5 seconds sometimes. I've pasted below a bit of the output of my vim --startuptime vim.log test.fish command. Is there any way to improve the performance? I'm not sure if it's just me, but I'd definitely like to use this plugin without the startuptime lag

152.351  000.095  000.095: sourcing /usr/local/Cellar/neovim/0.1.2/share/nvim/runtime/plugin/vimballPlugin.vim
152.531  000.138  000.138: sourcing /usr/local/Cellar/neovim/0.1.2/share/nvim/runtime/plugin/zipPlugin.vim
152.600  002.106: loading plugins
152.606  000.006: inits 3
156.487  003.881: reading ShaDa
157.076  000.589: clearing screen
165.099  001.021  001.021: sourcing /usr/local/Cellar/neovim/0.1.2/share/nvim/runtime/scripts.vim
2122.220  1956.397  1956.397: sourcing /Users/Kyle/.config/nvim/bundle/vim-fish/ftplugin/fish.vim
2122.991  000.027  000.027: sourcing /Users/Kyle/.config/nvim/bundle/vim-fish/indent/fish.vim
2123.407  000.110  000.110: sourcing /Users/Kyle/.config/nvim/bundle/vim-fish/syntax/fish.vim
2123.910  000.191  000.191: sourcing /Users/Kyle/.config/nvim/bundle/vim-airline/autoload/airline/extensions.vim

pushd and popd are considered errors

The following script

pushd foo
popd

will cause errors when validated with syntastic or the supplied fish compiler:

:!fish --no-execute /tmp/bug.fish  2>&1| tee /tmp/nvimVvLAs5/100
/tmp/bug.fish (line 1):
pushd foo
^
/tmp/bug.fish (line 2):
popd
^

Comments are replaced by empty lines

When editing a function with funced, the commented lines are replaced by empty lines.

This happens only if I use vim with this plugin and using the funced program.
Removing this plugin, or not sourcing any files by setting the -u flag for vim, I don't have this problem.
Simply calling vim test_function.fish will not trigger it either.

I don't see why it happens with funced, and maybe I did not properly probe the error. But it certainly is vim-fish which is causing the issue.

Unknown option error on start up

screen shot 2016-10-18 at 9 56 47 am

Any time I view a .fish file I get this warning. This is new. I've used this plugin for years.

The syntax highlighting still totally works.

Any ideas?

Line continuations

If a line ends with a backslash, the following line should highlight as being in argument position and possibly be indented two or three levels more than the previous line, unless that line too was a line continuation (but the editor in fish does not indent continued lines).

  • syntax
  • endwise
  • completion
  • folding
  • indent

HOW TO INSTALL?

I am sorry, but this is a basic question - not an issue

How on hell do you install this project in VIM?

For the novice it is far from trivial looking at the readme.
Please provide directions. I use spf13, anything special I should do?

Thank you

A fork that I indend to maintain

Hi,

I've created a fork and merged some of the open prs.

Please see this issue: blankname/issues/1

This is my first time doing this and I'm not exactly sure what the proper etiquette is, so feel free to delete this issue if it's inappropriate to post an issue about a fork like this.

I will also delete this issue myself if someone informs me that it's inappropriate.

And to repeat what I say in the issue I linked above, thanks again for creating this project.

Drop or improve the funced behavior

After using it for a while I can only conclude that it's an annoyance, especially being put in Insert mode, and I've also since discovered better ways to work with funced in Vim. It might still be useful to do something like, move the cursor to the first line following a function start declaration, but stay in Normal mode and don't indent. The user then just has to hit S (or cc) to start Insert and indent.

Combinator builtins

For example, code like this is perfectly valid:

false
or begin
    ...
end

However currently if you type this the third line will not be automatically indented, and if you use endwise the end will actually be dedented one level more than the or begin!

To solve this we need a list of all these "combinator" builtins (only builtins have this power), and also remember that they can be chained, for example if not begin. Also, the b option should perhaps be removed from some or all of the UltiSnips snippets.

E484: Can't open file /tmp/vnKV0xX/0 at Vim startup

A try to edit .fish file ends with the following error message:

"z.fish" 196L, 6779C
Error detected while processing ~/.vim/bundle/vim-fish/ftplugin/fish.vim:
line   22:
E484: Can't open file /tmp/v8jnFvB/0

After Enter I can edit a file anyway having syntax highlighting enabled. The latest vim-fish version installed using vundle.

Vim 7.4.027, fish 2.1.0, Fedora 18.

funced support

Plugin works great with vim *.fish, thanks so much for it!

Do you know how to get it to work with the funced command?

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.