I'm setting up Neovim like this guy in this video: https://www.youtube.com/watch?v=vdn_pKJUda8&t=145s&ab_channel=JoseanMartinez
I'm using WSL - Windows subsystem for Linux.
And I have this error in ~/.config/nvim/lua/suleiman/plugins-setup.lua file:
Error detected while processing /home/suleiman/.config/nvim/init.lua:
E5113: Error while calling lua chunk: vim/_init_packages.lua:0:
/home/suleiman/.config/nvim/lua/suleiman/plugins-setup.lua:24: '<eof>' expected near 'local'
stack traceback:
[C]: in function 'error'
vim/_init_packages.lua: in function <vim/_init_packages.lua:0>
[C]: in function 'require'
/home/suleiman/.config/nvim/init.lua:1: in main chunk
And here is the file itself:
vim.cmd([[
augroup packer_user_config
autocmd!
autocmd BufWritePost plugins.lua source <afile> | PackerCompile
augroup end
]])
local status, packer = pcall(require, 'packer')
if not status then
return
end
return packer.startup(function(use)
use('wbthomason/packer.nvim')
use('bluz71/vim-nightfly-guicolors')
if packer_bootstrap then
require('packer').sync()
end
end)
local ensure_packer = function() // This is the line:24
local fn = vim.fn
local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
if fn.empty(fn.glob(install_path)) > 0 then
fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
vim.cmd [[packadd packer.nvim]]
return true
end
return false
end
local packer_bootstrap = ensure_packer()
return require('packer').startup(function(use)
use 'wbthomason/packer.nvim'
-- My plugins here
-- use 'foo1/bar1.nvim'
-- use 'foo2/bar2.nvim'
-- Automatically set up your configuration after cloning packer.nvim
-- Put this at the end after all plugins
if packer_bootstrap then
require('packer').sync()
end
end)
plugins-setup.lua
And this is here is the ~/.config/nvim/init.lua file where I require that file:
require('suleiman.plugins-setup')
require('suleiman.core.options')
require('suleiman.core.keymaps')
require('suleiman.core.colorscheme')
I searched on this error, I didn't find the solution.
There isn't supposed to be an error at all I think, because I copied what that guy on that video did.
Related
I'm giving SpaceVim a try.
I want to install the following plugin (lewis6991/gitsigns.nvim)
I get the following error:
Error executing luv callback:
.../lewis6991/gitsigns.nvim/lua/gitsigns/async.lua:67: The coroutine failed with this message: [string ":lua"]:4: E5560: vimL function must not be called in a lua loop callback
I tried the following configurations (spacevim documentation)
Method 1
# ~/.SpaceVim.d/init.toml
[options]
...
bootstrap_after = 'myspacevim#after'
[[custom_plugins]]
name = 'lewis6991/gitsigns.nvim'
merged = false
# ~/.SpaceVim.d/autoload/myspacevim.vim
function! myspacevim#after() abort
lua << EOF
require('gitsigns').setup({})
EOF
endfunction
Method 2
# ~/.SpaceVim.d/init.toml
[[custom_plugins]]
name = 'lewis6991/gitsigns.nvim'
merged = false
hook_add = '''
lua << EOF
require('gitsigns').setup({})
EOF
'''
Without SpaceVim it's working perfectly with:
# ~/.config/nvim/init.vim
call plug#begin('~/.vim/plugged')
Plug 'lewis6991/gitsigns.nvim'
call plug#end()
lua << EOF
require('gitsigns').setup({})
EOF
Am I doing something wrong?
I would like to open a .4gl file in VI terminal and write to it, this is the code I have currently:
let p_command = "test -f ", MTGENDIR CLIPPED,"/",p_prog clipped,".4gl"
run p_command returning p_status
let p_command = "vi ",p_prog clipped,".4gl"
--let p_command = "w ",p_prog clipped,".4gl"
--let p_command = ":w ",p_prog clipped,".4gl"
run p_command
This is the error I get in the debugger once it gets to the step vi and then it hangs:
(fgldb) next
376 let p_command = "vi ",p_prog clipped,".4gl"
(fgldb) next
377 run p_command
(fgldb) next
Vim: Warning: Output is not to a terminal
Vim: Warning: Input is not from a terminal
if i try writing with the commented code above (w or :w) it crashes and display this error:
The DVM process crashed. Please contact FourJs support.
DVM has encountered a problem. Execution of 'mt_gen' stopped
Is there any other way i can write to .4gl file in Genero?
To answer the very last sentence "Is there any other way I can write to .4gl file in Genero?" then you can use base.Channel class to write to a file ...
MAIN
DEFINE ch base.Channel
LET ch = base.Channel.create()
CALL ch.openFile("example.4gl","w")
CALL ch.writeLine("MAIN")
CALL ch.writeLine(" DISPLAY 'Hello World'")
CALL ch.writeLine("END MAIN")
CALL ch.close()
END MAIN
... the key bit being the use of base.Channel.openFile and w (or a) as the opening mode http://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_ClassChannel_openFile.html
Alternatively you can build up the file inside a STRING or base.StringBuffer variable and use the TEXT writeFile method http://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_datatypes_TEXT_writeFile.html ...
MAIN
DEFINE s STRING
DEFINE t TEXT
LET s =
"MAIN", ASCII(13),
" DISPLAY 'Hello World'", ASCII(13),
"END MAIN"
LOCATE t IN MEMORY
LET t = s
CALL t.writeFile("example2.4gl")
END MAIN
I'm not sure why you think you need vi/vim in your solution to write to a .4gl file.
I am using neovim and am trying to use lua for my settings.
I have installed vimwiki and following the instructions to set
let g:vimwiki_list = [{'path': '~/vimwiki/',
\ 'syntax': 'markdown', 'ext': '.md'}]
I have tried doing this in lua with
vim.api.nvim_set_var('vimwiki_list', {path = "~/mywiki/"})
This results in the error
Error detected while processing function vimwiki#vars#init[2]..<SNR>31_populate_wikilocal_options:
line 49:
E714: List required
Error detected while processing function <SNR>30_vimwiki_get_known_extensions:
line 3:
E727: Start past end
E714: List required
Error detected while processing /home/me/.local/share/nvim/site/pack/packer/start/vimwiki/plugin/vimwiki.vim:
line 303:
E714: List required
line 315:
E712: Argument of map() must be a List or Dictionary
E714: List required
Error detected while processing function <SNR>30_build_menu:
line 2:
E727: Start past end
E714: List required
How do I correctly set these type of options, specifically for vimwiki, and more generally for other cases?
I did;
vim.g.vimwiki_list = {{path = '~/Docs/Mywiki', syntax = 'markdown', ext = '.md'}}
which resolved the error and set the options
This is my current syntastic configuration:
let g:syntastic_check_on_open=1
let g:syntastic_quiet_messages = { "level": [] }
let g:syntastic_aggregate_errors = 1
let g:syntastic_javascript_checkers = ['jshint', 'jslint']
let g:syntastic_warning_symbol = 'WW'
let g:syntastic_error_symbol = 'EE'
The problem that I have is that, it shows only error messages in my javascript files:
For example:
% jslint web/js/app.js
web/js/app.js
#1 'define' was used before it was defined.
define([ // Line 1, Pos 1
#2 Expected exactly one space between 'function' and '('.
RestangularProvider.setResponseExtractor(function(response, operation) { // Line 73, Pos 58
but when I open the file in vim i see only the message #1 'define' was used before it was defined., not the second one.
What should I do to enable warnings to be shown too?
Syntastic uses the following command line options to jslint by default:
--white --nomen --regexp --plusplus --bitwise --newcap --sloppy --vars
(see syntastic/syntax_checkers/javascript/jslint.vim).
You can set your own options via
let g:syntastic_javscript_jslint_args = "--foo --bar --baz"
The --white from the defaults is what suppresses your second warning
In my vim plugin, I have two files:
myplugin/plugin.vim
myplugin/plugin_helpers.py
I would like to import plugin_helpers from plugin.vim (using the vim python support), so I believe I first need to put the directory of my plugin on python's sys.path.
How can I (in vimscript) get the path to the currently executing script? In python, this is __file__. In ruby, it's __FILE__. I couldn't find anything similar for vim by googling, can it be done?
Note: I am not looking for the currently edited file ("%:p" and friends).
" Relative path of script file:
let s:path = expand('<sfile>')
" Absolute path of script file:
let s:path = expand('<sfile>:p')
" Absolute path of script file with symbolic links resolved:
let s:path = resolve(expand('<sfile>:p'))
" Folder in which script resides: (not safe for symlinks)
let s:path = expand('<sfile>:p:h')
" If you're using a symlink to your script, but your resources are in
" the same directory as the actual script, you'll need to do this:
" 1: Get the absolute path of the script
" 2: Resolve all symbolic links
" 3: Get the folder of the resolved absolute file
let s:path = fnamemodify(resolve(expand('<sfile>:p')), ':h')
I use that last one often because my ~/.vimrc is a symbolic link to a script in a git repository.
Found it:
let s:current_file=expand("<sfile>")
It is worth mentioning that the above solution will only work outside of a function.
This will not give the desired result:
function! MyFunction()
let s:current_file=expand('<sfile>:p:h')
echom s:current_file
endfunction
But this will:
let s:current_file=expand('<sfile>')
function! MyFunction()
echom s:current_file
endfunction
Here's a full solution to OP's original question:
let s:path = expand('<sfile>:p:h')
function! MyPythonFunction()
import sys
import os
script_path = vim.eval('s:path')
lib_path = os.path.join(script_path, '.')
sys.path.insert(0, lib_path)
import vim
import plugin_helpers
plugin_helpers.do_some_cool_stuff_here()
vim.command("badd %(result)s" % {'result':plugin_helpers.get_result()})
EOF
endfunction
If you really want to get the script path inside a function (which is what I'd like to), you can still use <sfile>'s second semantic, or its equivalent <stack> inside expand().
<sfile> ...
When executing a legacy function, is replaced with the call
stack, as with <stack>
...
:<stack> <stack>
<stack> is replaced with the call stack, using
"function {function-name}[{lnum}]" for a function line
and "script {file-name}[{lnum}]" for a script line, and
".." in between items. E.g.:
"function {function-name1}[{lnum}]..{function-name2}[{lnum}]"
If there is no call stack you get error E489 .
However you possibly don't want to use it in a plugin, as you can use autoload functions in plugin, using this relative#path#to#plugin#root#script notation.
I use this for sourcing purpose:
function! s:SourceLocal(script)
let l:callstack = expand("<stack>")
let l:list = split(l:callstack, '\.\.')
" list[-1] is SourceLocal function itself
" list[-2] is the calling script
let l:script_name = matchstr(l:list[-2], '^\(script \)\=\zs.\+\ze\[\d\+\]$')
let l:script_path = fnamemodify(l:script_name, ":p:h")
" l:script_path is the path where the script calling this function resides
execute printf("source %s/%s", l:script_path, a:script)
endfunction
command! -nargs=1 SourceLocal :call s:SourceLocal(<f-args>)
Then you can SourceLocal inside any script to source another script relative to it.