Setting vimwiki_list in a lua.init file - vim

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

Related

Neovim config error: '<eof>' expected near 'local'

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.

Issues creating a virtual HANA table

I am trying to create a virtual table in HANA based on a remote system table view.
If I run it at the command line using hdbsql
hdbsql H00=> create virtual table HanaIndexTable at "SYSRDL#CG_SOURCE"."<NULL>"."dbo"."sysiqvindex"
0 rows affected (overall time 305.661 msec; server time 215.870 msec)
I am able to select from HanaIndexTable and get results and see my index.
When I code it in python, I use the following command:
cursor.execute("""create virtual table HanaIndexTable1 at SYSRDL#CG_source.\<NULL\>.dbo.sysiqvindex""")
I think there is a problem with the NULL. But I see in the output that the escape key is doubled.
self = <hdbcli.dbapi.Cursor object at 0x7f02d61f43d0>
operation = 'create virtual table HanaIndexTable1 at SYSRDL#CG_source.\\<NULL\\>.dbo.sysiqvindex'
parameters = None
def __execute(self, operation, parameters = None):
# parameters is already checked as None or Tuple type.
> ret = self.__cursor.execute(operation, parameters=parameters, scrollable=self._scrollable)
E hdbcli.dbapi.ProgrammingError: (257, 'sql syntax error: incorrect syntax near "\\": line 1 col 58 (at pos 58)')
/usr/local/lib/python3.7/site-packages/hdbcli/dbapi.py:69: ProgrammingError
I have tried to run the command without the <> but get the following error.
hdbcli.dbapi.ProgrammingError: (257, 'sql syntax error: incorrect syntax near "NULL": line 1 col 58 (at pos 58)')
I have tried upper case, lower case and escaping. Is what I am trying to do impossible?
There was an issue with capitalization between HANA and my remote source. I also needed more escaping rather than less.

Error when attempting to install Octave IO package

When attempting to install the Octave io package on Windows 7 I receive the following error:
>> pkg install io-2.4.12.tar.gz
0 [main] us 0 init_cheap: VirtualAlloc pointer is null, Win32 error 487
AllocationBase 0x0, BaseAddress 0x60EA0000, RegionSize 0x190000, State 0x10000
C:\Octave\Octave-4.2.0\bin\perl.exe: *** Couldn't reserve space for cygwin's heap, Win32 error 0
warning: doc_cache_create: unusable help text found in file 'getxmlattv'
For information about changes from previous versions of the io package, run 'news io'.
>>
I have a read a few other similar questions but have been unable to find an answer, and I do not understand the error message in all honesty. I understand cygwin in a Unix-like interface for windows, but that is about it. I have tried running as administrator, deleting all temp files, restarting etc. but cannot get the pkg to install successfully. Any ideas?
The referenced file 'getxmlattv' is just a function and not a text file as described and cannot be run as a standalone file:
function [retval] = getxmlattv (xmlnode, att)
retval = '';
## Get end of first tag
iend = index (xmlnode, ">");
## Get start of value string. Concat '="' to ensure minimal ambiguity
vals = index (xmlnode, [att '="']);
if (vals == 0)
## Attribute not in current tag
return
elseif (vals)
vals = vals + length (att) + 2;
vale = regexp (xmlnode(vals:end), '"[ >/]');
if (! isempty (vale))
retval = xmlnode(vals:vals+vale-2);
endif
endif
endfunction
I don't see how this is of any use.
For the windows version of octave the packages are already available in the installer
https://wiki.octave.org/Octave_for_Microsoft_Windows
so you don't need to install io from source package. Just re-run the installer
if you missed it.
Please note that the error message is misleading as you are not using the
cygwin version of octave but msys/mingw one; that is based on a modified
version of the cygwin1.dll where they forgot to update the messages:
$ strings msys-1.0.dll | grep cygwin
...
%P: *** Couldn't reserve space for cygwin's heap (%p <%p>) in child, %E
...

fread error? invalid file identifier

while executing, I have this error ?? Error using ==> fread
Invalid file identifier. Use fopen to generate a valid file identifier. fid is equal to -1 but the file does exist.
what shall I do?
seq=dir('C:\Windows\system32\config\systemprofile\Desktop\pfe\code final version 1\nor\info');
N=[];
for i = 3 : length(seq)
disp(seq(i).name)
cd 'C:\Windows\system32\config\systemprofile\Desktop\pfe\code final version 1\nor\info'
fin = fopen('seq(i).name','r');
[x,count]=fread(fin,'char=>char');
cd 'C:\Windows\system32\config\systemprofile\Desktop\pfe\code final version 1'
M=fichier(fin,x);
N=[N;M];
end
xlswrite('info.xls',N);
As you put '' around the name, you are trying to open a file called seq(i).name, remove the '' and you are using the variable named seq(i).name
fin = fopen(seq(i).name,'r');

Lua script unable to detect/catch error while executing invalid linux command

I have the following function that works fine as long as I give it a valid command to execute. As soon as I give it a non-existent command, the script is interrupted with an error message.
#!/usr/bin/lua
function exec_com(com)
local ok,res=pcall(function() return io.popen(com) end)
if ok then
local tmp=res:read('*a')
res:close()
return ok,tmp
else
return ok,res
end
end
local st,val=exec_com('uptime')
print('Executed "uptime" with status:'..tostring(st)..' and value:'..val)
st,val=exec_com('zzzz')
print('Executed "zzzz" with status:'..tostring(st)..' and value:'..val)
When I run the script above I get the following output:
Executed "uptime" with status:true and value: 18:07:38 up 1 day, 23:00, 3 users, load average: 0.37, 0.20, 0.20
sh: zzzz: command not found
Executed "zzzz" with status:true and value:
You can clearly see above that pcall() function still reported success when executing "zzzz" which is odd.
Can someone help me devise a way to catch an exception when executing a non-existent or ill-formed Linux command using Lua script? Thanks.
Edit: Restated my request after getting the clarification that pcall() works as expected, and the problem is due to popen() failing to throw an error.
I use a method which is similar to your "temporary workaround" but which gives you more information:
local cmd = "uptime"
local f = io.popen(cmd .. " 2>&1 || echo ::ERROR::", "r")
local text = f:read "*a"
if text:find "::ERROR::" then
-- something went wrong
print("error: " .. text)
else
-- all is fine!!
print(text)
end
If you look at io.popen(), you'll see that it'll always return a file handle.
Starts program prog in a separated process and returns a file handle
that you can use to read data from this program (if mode is "r", the
default) or to write data to this program (if mode is "w").
Since, a file handle returned is still a valid value for lua, the pcall(), your local function inside the pcall is returning a true value (and an error is not being propagated); thereby, giving you a true status and no output.
I have come up with my own temporary workaround that pipes the error to /dev/null and determines the success/failure of executed command based on the text received from io.popen():read('*a') command.
Here is my new code:
#!/usr/bin/lua
function exec_com(com)
local res=io.popen(com..' 2>/dev/null')
local tmp=res:read('*a')
res:close()
if string.len(tmp)>0 then
return true,tmp
else
return false,'Error executing command: '..com
end
end
local st,val=exec_com('uptime')
print('Executed "uptime" with status:'..tostring(st)..' and value:'..val)
st,val=exec_com('cat /etc/shadow')
print('Executed "cat /etc/shadow" with status:'..tostring(st)..' and value:'..val)
And the corresponding output is now correct:
Executed "uptime" with status:true and value: 00:10:11 up 2 days, 5:02, 3 users, load average: 0.01, 0.05, 0.19
Executed "cat /etc/shadow" with status:false and value:Error executing command: cat /etc/shadow
In my example above I am creating a "generic" error description. This is an intermediate fix and I am still interested in seeing alternative solutions that can return a more meaningful error message describing why the command failed to execute.
Rather than taking the time reading the whole file into a variable, why not just check if the file is empty with f:read(0)?
Local f = io.popen("NotExist")
if not f:read(0) Then
for l in st:lines() do
print(l)
end
else
error("Command Does Not Exist")
end
From the lua Manual:
As a special case, io.read(0) works as a test for end of file: It returns an empty string if there is more to be read or nil otherwise.

Resources