Giter VIP home page Giter VIP logo

v-vim's Introduction

Support for V in Vim

The files in this repository provide support for the v programming language in Vim.

Installation

Using a Plugin Manager

You can install V support with a vim plugin manager as usual, for example with Plug:

Plug 'ollykel/v-vim'

Reload config (or save & exit vim/neovim), then:

:PlugInstall

Options

You can add any of the following into your vim config to disable highlighting.
The following options are enabled by default:

" Disable highlight white space after "[]".
let g:v_highlight_array_whitespace_error = 0

" Disable highlight white space around the communications operator that don't follow the standard style.
let g:v_highlight_chan_whitespace_error = 0

" Disable highlight instances of tabs following spaces.
let g:v_highlight_space_tab_error = 0

" Disable highlight trailing white space.
let g:v_highlight_trailing_whitespace_error = 0

" Disable highlight function calls.
let g:v_highlight_function_calls = 0

let g:v_highlight_fields = 0

You can add any of the following to your vim config to enable aditional options. The following options are disabled by default:

" Enable automatically formatting file via "v fmt -" before writing buffer.
let g:v_autofmt_bufwritepre = 1

v-vim's People

Contributors

ollykel avatar netmute avatar ernierasta avatar sheerun avatar rcorre avatar zakuro9715 avatar gladear avatar subnut avatar tristancrawford avatar thomaskasper8 avatar

Stargazers

Salvador Guzman avatar Anilcan KARA avatar Sigui Kessé Emmanuel avatar Tom avatar  avatar Pixeller avatar Volker Bernhard Duetsch avatar shuyue avatar Koosha Yeganeh avatar momo avatar Mr-Fox-h avatar Comamoca avatar integrate-your-mind avatar Anthony Perrett avatar  avatar Yagizalp Zaimoglu avatar Renzo Mondragón avatar Ahmad avatar Marouane avatar BZK avatar José Luis Cruz avatar Marcos Cruz avatar Petr Makhnev avatar  avatar  avatar Konosuke Sakai avatar Tobias Neitzel avatar Vítor Mariano avatar Baptiste Canton avatar Dich0tomy avatar Stanislav Derevianko avatar 8dcc  avatar Alexey Sokolov avatar Jon Mayo avatar Leo Liu avatar Ulrich Anhalt avatar Ғ☈ᰀↁ avatar  avatar Lucid Developer avatar  avatar whiter001 avatar tk0h avatar Norman Sue avatar  avatar SPARON avatar Dave VanderWeele avatar LuizF avatar Tejas Agarwal avatar Joshua Peisach avatar Nicolas Sauzede avatar  avatar Hyun Yi avatar Leo avatar Ryder Rishel avatar  avatar Eric Tenza avatar Peter A. avatar Josué Teodoro Moreira avatar Roman avatar Regan Koopmans avatar Ellie avatar Xavier Mitault avatar Sunil Janki avatar ahnan avatar Marcel Guinhos avatar ilbaroni avatar Dong Nguyen avatar  avatar Engiseer avatar Rafael Escobar avatar Abu Ghurab avatar Simon avatar Conscat avatar Thomas Dost avatar Abderahmane Bouziane avatar  avatar Sergiu avatar  avatar shadow avatar  avatar Doğu Us avatar Rieger avatar  avatar Komil Sobitov avatar heapwolf avatar 2pac avatar Metehan Gülaç avatar Farbod Shahinfar avatar Dmitry Shvetsov avatar Austen avatar Larry Z. avatar Matheus Francisco avatar Lucas Eduardo avatar  avatar Dicha Zelianivan Arkana avatar  avatar ihsan avatar mlevesquedion avatar Jeremy Bae avatar  avatar

Watchers

 avatar Adelar da Silva Queiróz avatar  avatar  avatar

v-vim's Issues

Doesn't handle strings well (single and double quote)

Summary

Multiple strings on one line are not handled well.

image

Steps to reproduce

  • Neovim version: NVIM v0.8.0-dev+430-g0c6ad03c3
  • Using colorscheme github.com/ful1e5/onedark.nvim

Open a .v file with this content:

module main

import os
import flag

fn add_path(path string) {
	println("hello from add_path")
}

fn main() {
	mut fp := flag.new_flag_parser(os.args)
    fp.application("z.v")
    fp.version("v0.0.1")
    fp.description("jump around")
    fp.limit_free_args(0, 0)
    fp.skip_executable()
    a_bool := fp.string("add", 0, "", "add directory to zdata")
    println("aa_bool: $a_bool")
}

Expected Behavior

Strings should be green.

Observed Behavior

As shown above.

Auto format the file on the save using !v fmt

Using plugins like Prettier on javascript files, when a file is saved in vim the prettier command will get run over the file and the contents updated according to prettier's formatting rules.

I notice the same is available for v, in the v's binary as an option.

Would it be in the scope of this plugin to detect if the v binary is in the path (or perhaps an option to point to the v binary) and run v fmt over the contents on save?

Mention vim plugin managers in readme

Hi!
Thank you for this!
Maybe it is worth mentioning in readme, that it can be easily installed with plugin managers. I tested it with Plug, just add:
Plug 'ollykel/v-vim'
then install as usual with :PlugInstall.
And you are good to go!

v_autofmt_bufwritepre appends trailing newline

Issues

Please read thoroughly before submitting an issue.


Bug Reports

Before filing a bug report, make sure to search for existing issues to make
sure it hasn't been reported already. If it hasn't, follow the format below to
file a new issue:

Summary

Saving a file with v_autofmt_bufwritepre appends a trailing newline.

Steps to reproduce

How to reproduce the issue. Things you should mention include:

  • Vim version:
NVIM v0.4.4
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/bin/cc -D_FORTIFY_SOURCE=2 -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/build/neovim/src/build/config -I/build/neovim/src/neovim-0.4.4/src -I/usr/include -I/build/neovim/src/build/src/nvim/auto -I/build/neovim/src/build/include
Compiled by builduser

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info
  • Vim variables and settings during error

  • Relevant portions of your vimrc

Entire vimrc:

call plug#begin('~/.config/nvim/plugged')
Plug 'ollykel/v-vim'
call plug#end()
let g:v_autofmt_bufwritepre = 1
  • Other plugins you have installed, particularly ones that may affect the issue
    at hand.

None, running with minimal vimrc above

Expected Behavior

Formatting matches v fmt.

Observed Behavior

  • Place the above vimrc in tmp.vim
  • Run vim -u tmp.vim example.v
  • Write println("foo")
  • Run :w
  • vim appends a newline
  • run v fmt -diff example.v
  • note that the diff removes the newline

Errors on formatting buffer via vfmt disappears after some time

Summary

Errors on formatting buffer via vfmt disappears after some time

Steps to reproduce

  • Vim version : version 8.2.2891

plugins:

Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'fatih/vim-go'
Plug 'AndrewRadev/splitjoin.vim'
Plug 'tweekmonster/gofmt.vim'
Plug 'mbbill/undotree'
Plug 'hashivim/vim-terraform'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'arcticicestudio/nord-vim'
Plug 'vim-airline/vim-airline'
Plug 'flazz/vim-colorschemes'
Plug 'preservim/nerdtree'
Plug 'python-mode/python-mode', { 'for': 'python', 'branch': 'develop' }
Plug 'editorconfig/editorconfig-vim'
Plug 'vim-scripts/groovy.vim'
Plug 'NLKNguyen/papercolor-theme'
Plug 'ollykel/v-vim'

vimrc:

" v settings
"
" Disable highlight white space after "[]".
let g:v_highlight_array_whitespace_error = 0

" Disable highlight white space around the communications operator that don't follow the standard style.
let g:v_highlight_chan_whitespace_error = 1

" Disable highlight instances of tabs following spaces.
let g:v_highlight_space_tab_error = 1

" Disable highlight trailing white space.
let g:v_highlight_trailing_whitespace_error = 1

" Disable highlight function calls.
let g:v_highlight_function_calls = 1

let g:v_highlight_fields = 1

" Enable automatically formatting file via "v fmt -" before writing buffer.
let g:v_autofmt_bufwritepre = 1

Expected Behavior

2021-08-18_01-10

Observed Behavior

Error detected while processing BufWrite Autocommands for "*.v"..function _VFormatFile:
line    4:
While formatting the buffer via vfmt, the following error occurred:
line    5:
"bla.v" 4L, 33B written
Press ENTER or type command to continue

2021-08-18_01-111

Explanation

Errors on formatting buffer via vfmt disappears after some time. I am not sure whether it bug or not...

Implementation

Unfortunately, I have not ideas how to fix it :( I would really be interested in helping but even can't recognize this is an error of my setup or v-vim plugin. It might be reasonable to open a new buffer (I guess vim-go acts like this) for errors:
image

Appreciate your time and suggestions. Thanks!

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.