I receive this error every time I try to write code in nvim, in any file it does not matter if it is not python, I just installed vim and what I did is copy a repository, I don't know which part could be wrong, also mention that the paths are /user/.vim, and that the repository that I clone for this is from a person with mac.
This is the UltiSnips.vim:
if exists("b:did_autoload_ultisnips")
finish
endif
let b:did_autoload_ultisnips = 1
" Also import vim as we expect it to be imported in many places.
py3 import vim
py3 from UltiSnips import UltiSnips_Manager
function! s:compensate_for_pum() abort
""" The CursorMovedI event is not triggered while the popup-menu is visible,
""" and it's by this event that UltiSnips updates its vim-state. The fix is
""" to explicitly check for the presence of the popup menu, and update
""" the vim-state accordingly.
if pumvisible()
py3 UltiSnips_Manager._cursor_moved()
endif
endfunction
function! UltiSnips#Edit(bang, ...) abort
if a:0 == 1 && a:1 != ''
let type = a:1
else
let type = ""
endif
py3 vim.command("let file = '%s'" % UltiSnips_Manager._file_to_edit(vim.eval("type"), vim.eval('a:bang')))
if !len(file)
return
endif
let mode = 'e'
if exists('g:UltiSnipsEditSplit')
if g:UltiSnipsEditSplit == 'vertical'
let mode = 'vs'
elseif g:UltiSnipsEditSplit == 'horizontal'
let mode = 'sp'
elseif g:UltiSnipsEditSplit == 'tabdo'
let mode = 'tabedit'
elseif g:UltiSnipsEditSplit == 'context'
let mode = 'vs'
if winwidth(0) <= 2 * (&tw ? &tw : 80)
let mode = 'sp'
endif
endif
endif
exe ':'.mode.' '.escape(file, ' ')
endfunction
function! UltiSnips#AddFiletypes(filetypes) abort
py3 UltiSnips_Manager.add_buffer_filetypes(vim.eval("a:filetypes"))
return ""
endfunction
function! UltiSnips#FileTypeComplete(arglead, cmdline, cursorpos) abort
let ret = {}
let items = map(
\ split(globpath(&runtimepath, 'syntax/*.vim'), '\n'),
\ 'fnamemodify(v:val, ":t:r")'
\ )
call insert(items, 'all')
for item in items
if !has_key(ret, item) && item =~ '^'.a:arglead
let ret[item] = 1
endif
endfor
return sort(keys(ret))
endfunction
function! UltiSnips#ExpandSnippet() abort
py3 UltiSnips_Manager.expand()
return ""
endfunction
function! UltiSnips#ExpandSnippetOrJump() abort
call s:compensate_for_pum()
py3 UltiSnips_Manager.expand_or_jump()
return ""
endfunction
function! UltiSnips#ListSnippets() abort
py3 UltiSnips_Manager.list_snippets()
return ""
endfunction
function! UltiSnips#SnippetsInCurrentScope(...) abort
let g:current_ulti_dict = {}
let all = get(a:, 1, 0)
if all
let g:current_ulti_dict_info = {}
endif
py3 UltiSnips_Manager.snippets_in_current_scope(int(vim.eval("all")))
return g:current_ulti_dict
endfunction
function! UltiSnips#SaveLastVisualSelection() range abort
py3 UltiSnips_Manager._save_last_visual_selection()
return ""
endfunction
function! UltiSnips#JumpBackwards() abort
call s:compensate_for_pum()
py3 UltiSnips_Manager.jump_backwards()
return ""
endfunction
function! UltiSnips#JumpForwards() abort
call s:compensate_for_pum()
py3 UltiSnips_Manager.jump_forwards()
return ""
endfunction
function! UltiSnips#AddSnippetWithPriority(trigger, value, description, options, filetype, priority) abort
py3 trigger = vim.eval("a:trigger")
py3 value = vim.eval("a:value")
py3 description = vim.eval("a:description")
py3 options = vim.eval("a:options")
py3 filetype = vim.eval("a:filetype")
py3 priority = vim.eval("a:priority")
py3 UltiSnips_Manager.add_snippet(trigger, value, description, options, filetype, priority)
return ""
endfunction
function! UltiSnips#Anon(value, ...) abort
" Takes the same arguments as SnippetManager.expand_anon:
" (value, trigger="", description="", options="")
py3 args = vim.eval("a:000")
py3 value = vim.eval("a:value")
py3 UltiSnips_Manager.expand_anon(value, *args)
return ""
endfunction
function! UltiSnips#CursorMoved() abort
py3 UltiSnips_Manager._cursor_moved()
endf
function! UltiSnips#LeavingBuffer() abort
let from_preview = getwinvar(winnr('#'), '&previewwindow')
let to_preview = getwinvar(winnr(), '&previewwindow')
if !(from_preview || to_preview)
py3 UltiSnips_Manager._leaving_buffer()
endif
endf
function! UltiSnips#LeavingInsertMode() abort
py3 UltiSnips_Manager._leaving_insert_mode()
endfunction
function! UltiSnips#TrackChange() abort
py3 UltiSnips_Manager._track_change()
endfunction
function! UltiSnips#RefreshSnippets() abort
py3 UltiSnips_Manager._refresh_snippets()
endfunction
" }}}
Your error is mostly because you don't have the pynvim Python package installed. Do a pip install pynvim and it should work.
Be careful because I couldn't make it work with latest version of python (3.9), as it says it needs Build Tools for C++.
Related
ValueType := A_Args[1]
KeyName := A_Args[2]
ValueName := A_Args[3]
ValueData := A_Args[4]
Loop, %0%
params .= A_Space %A_Index%
; https://autohotkey.com/docs/Run#RunAs
full_command_line := DllCall("GetCommandLine", "str")
if !(A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)")) {
try {
if A_IsCompiled
Run *RunAs "%A_ScriptFullPath%" "%params%" /restart
else
Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%" "%params%"
}
ExitApp
}
RegWrite, % ValueType, % KeyName, % ValueName, % ValueData
Why is RegWrite not writing to the registry when I pass parameters to the script?
A_LastError codes
Code 87 means an invalid parameter. What are you passing to RegWrite?
Here's one function I use for debugging. If isCondition is true it shows a custom error message and stops everything.
fAbort(isCondition, sFuncName, sNote, dVars:="") {
If isCondition {
sAbortMessage := % sFuncName ": " sNote
. "`n`nA_LineNumber: """ A_LineNumber """`nErrorLevel: """ ErrorLevel """`nA_LastError: """ A_LastError """`n"
For sName, sValue in dVars
sAbortMessage .= "`n" sName ": """ sValue """"
MsgBox, 16,, % sAbortMessage
ExitApp
}
}
After a RegWrite it could be used like this:
fAbort(ErrorLevel ; 1, if RegWrite unsuccessful.
, "Script or function name here" ; Could use A_ThisFunc for current function name.
, "Registry write unsuccessful." ; Your custom message here.
, { x: "blabla", y: 13 } ; Additional vars you want to see in the msgbox.
)
Hello I tried to enter a js file and upon entering I got this error:
Error detected while processing function SwitchFlowOrTsLsps:
line 4:
E121: Undefined variable: state
E15: Invalid expression: (tsserver.state == 'disabled')
Try to find the line that tells me in the different files such as maps, plugin or plugin config, the last one is the one I found it in, before I did not suffer from this error because I was only entering py, cpp and java extension files, I have the coc, but do not download anything for this, I also have the kite installed as a plugin for autocompletion
" HTML, JSX
let g:closetag_filenames = '*.html,*.js,*.jsx,*.ts,*.tsx'
" Lightlane
let g:lightline = {
\ 'active': {
\ 'left': [['mode', 'paste'], [], ['relativepath', 'modified']],
\ 'right': [['kitestatus'], ['filetype', 'percent', 'lineinfo'], ['gitbranch']]
\ },
\ 'inactive': {
\ 'left': [['inactive'], ['relativepath']],
\ 'right': [['bufnum']]
\ },
\ 'component': {
\ 'bufnum': '%n',
\ 'inactive': 'inactive'
\ },
\ 'component_function': {
\ 'gitbranch': 'fugitive#head',
\ 'cocstatus': 'coc#status'
\ },
\ 'colorscheme': 'gruvbox',
\ 'subseparator': {
\ 'left': '',
\ 'right': ''
\ }
\}
" nerdtree
let NERDTreeShowHidden=1
let NERDTreeQuitOnOpen=1
let NERDTreeAutoDeleteBuffer=1
let NERDTreeMinimalUI=1
let NERDTreeDirArrows=1
let NERDTreeShowLineNumbers=1
let NERDTreeMapOpenInTab='\t'
let g:javascript_plugin_flow = 1
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
let g:UltiSnipsSnippetDirectories=[$HOME.'/config/.vim/UltiSnips']
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<S-tab>"
" deoplete
let g:deoplete#enable_at_startup = 1
let g:neosnippet#enable_completed_snippet = 1
" kite
let g:kite_supported_lenguages = ['javascript', 'python']
" coc
autocmd FileType python let b:coc_suggest_disable = 1
autocmd FileType javascript let b:coc_suggest_disable = 1
autocmd FileType scss setl iskeyword+=#-#
command! -bang -nargs=? -complete=dir GFiles
\ call fzf#vim#gitfiles(<q-args>, fzf#vim#with_preview(), <bang>0)
command! -bang -nargs=* Ag
\ call fzf#vim#ag(<q-args>, fzf#vim#with_preview(), <bang>0)
command! -bang -nargs=? -complete=dir Files
\ call fzf#vim#files(<q-args>, fzf#vim#with_preview(), <bang>0)
" if hidden is not set, TextEdit might fail.
set hidden
" Some servers have issues with backup files, see #649
set nobackup
set nowritebackup
" Better display for messages
set cmdheight=2
" You will have bad experience for diagnostic messages when it's default 4000.
set updatetime=300
" don't give |ins-completion-menu| messages.
set shortmess+=c
" always show signcolumns
set signcolumn=yes
" fugitive always vertical diffing
set diffopt+=vertical
" Use <c-space> to trigger completion.
inoremap <silent><expr> <c-space> coc#refresh()
" Remap keys for gotos
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" Highlight symbol under cursor on CursorHold
autocmd CursorHold * silent call CocActionAsync('highlight')
autocmd BufEnter *.js :silent let myIndex = SearchPatternInFile("#flow") | call SwitchFlowOrTsLsps(myIndex)
autocmd BufEnter *.jsx :silent let myIndex = SearchPatternInFile("#flow") | call SwitchFlowOrTsLsps(myIndex)
function! SwitchFlowOrTsLsps(flowIndex)
silent let stats = CocAction("extensionStats")
silent let tsserver = get(filter(copy(stats), function('FindTsServer')), 0)
if(a:flowIndex == 0)
if(tsserver.state == 'disabled')
call CocActionAsync("toggleExtension", "coc-tsserver")
endif
else
if(tsserver.state == 'activated')
call CocActionAsync("toggleExtension", "coc-tsserver")
endif
endif
endfunction
function! FindTsServer(idx, value)
return a:value.id == 'coc-tsserver'
endfunction
let $FZF_DEFAULT_OPTS='--layout=reverse'
let g:fzf_layout = { 'window': 'call FloatingFZF()' }
function! FloatingFZF()
let buf = nvim_create_buf(v:false, v:true)
call setbufvar(buf, '&signcolumn', 'no')
let height = float2nr((&lines - 3) / 2)
let width = float2nr(&columns - (&columns * 2 / 10))
let col = float2nr((&columns - width) / 2)
let row = float2nr((&lines - height) / 2)
let opts = {
\ 'relative': 'editor',
\ 'row': row,
\ 'col': col,
\ 'width': width,
\ 'height': height
\ }
call nvim_open_win(buf, v:true, opts)
endfunction
function! SearchPatternInFile(pattern)
" Save cursor position.
let save_cursor = getcurpos()
" Set cursor position to beginning of file.
call cursor(0, 0)
" Search for the string 'hello' with a flag c. The c flag means that a
" match at the cursor position will be accepted.
let search_result = search(a:pattern, "c")
" Set the cursor back at the saved position. The setpos function was
" used here because the return value of getcurpos can be used directly
" with it, unlike the cursor function.
call setpos('.', save_cursor)
" If the search function didn't find the pattern, it will have
" returned 0, thus it wasn't found. Any other number means that an instance
" has been found.
return search_result
endfunction
How could I solve it?, thanks to all.
Can you try running this command on vim and see if it works?
:CocInstall coc-json coc-tsserver
How to build a new kind of syntax which when has been called run it's value in os.system
while True:
a=input('enter your direction: ')
if a!='':
!dir !+Shell(a)
else:
print('the dir can not be None')
Based on your clarification, maybe this would work for you:
import subprocess
while True:
cmd = input("Enter a command: ")
if cmd != "":
cmd = cmd.split("!")[1]
subprocess.call(cmd, shell=True)
else:
print("Input cannot be None")
Using jScript to run a command line remotely. The first three commands work fine. It is not until i get to the dot command after I have opened the sqlite3 data base that it just stops executing. When I run .quit I either get
sqlite> .quit
The filename, directory name, or volume label syntax is incorrect.
or ".import" is not recognized as an internal or external command.
try {
// var ret = oShell.Run('cmd.exe cd c:\\sqlite', 1 /* SW_SHOWNORMAL */, true /* bWaitOnReturn */);
var oShell = WScript.CreateObject("WScript.Shell");
// var ret = oShell.Run("cmd.exe /k #echo Hello", 1 /* SW_SHOWNORMAL */, true/* bWaitOnReturn */);
var ret = oShell.Run('cmd.exe /k cd c:\\sqlite && #echo ".import H:\\\\2019\\\\00028-000-19\\\\QPPData\\\\Directory_Proofs\\\\Index_007.txt test" && sqlite3 F:\\qpp.db; && ".import H:\\\\2019\\\\00028-000-19\\\\QPPData\\\\Directory_Proofs\\\\Index_007.txt test"', 1 /* SW_SHOWNORMAL */, true/* bWaitOnReturn */);
WScript.Echo("ret " + ret);
//var ret = oShell.Run('cmd cd', 1 /* SW_SHOWNORMAL */, true /* bWaitOnReturn */);
}
catch (err) {
WScript.Echo(err);
}
I am making a python CLI utility that will answer questions like "15 + 15" or "How many letters are in the alphabet".
I then decided to add the ability to search up the latest news using the newspaper module.
All of it works except when the for loop finishes, after printing a string literal, it gives me a error that I do not know what the heck it means.
Can someone decipher the error for me and if possible, help me fix the error? Thanks.
import requests
import wolframalpha
import wikipedia
import time
import sys
from threading import Thread
from newspaper import Article
import bs4
from bs4 import BeautifulSoup as soup
from urllib.request import urlopen
version = 2.1
build = '19w12a6'
ready = 0
loadingAnimationStop = 0
appId = 'CENSORED STUFF BECAUSE I DON\'T WANT ANYONE TO TOUCH MY KEY'
client = wolframalpha.Client(appId)
exitNow = 0
def loadingAnimation():
while exitNow == 0:
print("Loading: |", end='\r')
time.sleep(0.2)
while ready == 1:
time.sleep(0)
print("Loading: /", end='\r')
time.sleep(0.2)
while ready == 1:
time.sleep(0)
print("Loading: -", end='\r')
time.sleep(0.2)
while ready == 1:
time.sleep(0)
sys.stdout.write("Loading: \ \r")
time.sleep(0.2)
while ready == 1:
time.sleep(0)
hui = Thread(target = loadingAnimation, args=())
hui.start()
def search_wiki(keyword=''):
searchResults = wikipedia.search(keyword)
if not searchResults:
print("No result from Wikipedia")
return
try:
page = wikipedia.page(searchResults[0])
except wikipedia.DisambiguationError:
page = wikipedia.page(err.options[0])
wikiTitle = str(page.title.encode('utf-8'))
wikiSummary = str(page.summary.encode('utf-8'))
print(' ', end='\r')
print(wikiTitle)
print(wikiSummary)
def search(text=''):
res = client.query(text)
if res['#success'] == 'false':
ready = 1
time.sleep(1)
print('Query cannot be resolved')
else:
result = ''
pod0 = res['pod'][0]
pod1 = res['pod'][1]
if (('definition' in pod1['#title'].lower()) or ('result' in pod1['#title'].lower()) or (pod1.get('#primary','false') == 'True')):
result = resolveListOrDict(pod1['subpod'])
ready = 1
time.sleep(0.75)
print(' ', end='\r')
print(result)
question = resolveListOrDict(pod0['subpod'])
question = removeBrackets(question)
#primaryImage(question)
else:
question = resolveListOrDict(pod0['subpod'])
question = removeBrackets(question)
search_wiki(question)
def removeBrackets(variable):
return variable.split('(')[0]
def resolveListOrDict(variable):
if isinstance(variable, list):
return variable[0]['plaintext']
else:
return variable['plaintext']
#def primaryImage(title=''):
# url = 'http://en.wikipedia.org/w/api.php'
# data = {'action':'query', 'prop':'pageimages','format':'json','piprop':'original','titles':title}
# try:
# res = requests.get(url, params=data)
# key = res.json()['query']['pages'].keys()[0]
# imageUrl = res.json()['query']['pages'][key]['original']['source']
# print(imageUrl)
# except Exception:
# print('Exception while finding image:= '+str(err))
page = requests.get('https://www.wolframalpha.com/')
s = page.status_code
if (s != 200):
ready = 1
time.sleep(1)
print('It looks like https://www.wolframalpha.com/ is not online.')
print('Please check your connection to the internet and https://www.wolframalpha.com/')
print('Stopping Python Information Engine')
while True:
time.sleep(1)
page = requests.get('https://www.wikipedia.org/')
s = page.status_code
if (s != 200):
ready = 1
time.sleep(1)
print('It looks like https://www.wikipedia.org/ is not online.')
print('Please check your connection to the internet and https://www.wikipedia.org/')
print('Stopping Python Information Engine')
while True:
time.sleep(1)
ready = 1
while exitNow == 0:
print('================================================================================================')
print('Python Information Engine CLI Version', end=' ')
print(version)
print('Create by Unsigned_Py')
print('================================================================================================')
ready = 1
time.sleep(1)
print(' ', end='\r')
print(' ', end='\r')
q = input('Search: ')
print('================================================================================================')
if (q == 'Credits()'):
print('Credits')
print('================================================================================================')
print('PIE is made by Unsigned_Py')
print('Unsigned_Py on the Python fourms: https://python-forum.io/User-Unsigned-Py')
print('Contact Unsigned_Py: Ckyiu#outlook.com')
if (q == 'Latest News'):
print('DISCLAIMER: The Python Information Engine News port is still in DEVELOPMENT!')
print('Getting latest news links from Google News...')
ready = 0
news_url = "https://news.google.com/news/rss"
Client = urlopen(news_url)
xml_page = Client.read()
Client.close()
soup_page = soup(xml_page,"xml")
news_list = soup_page.findAll("item")
ready = 1
print('================================================================================================')
article_number = 1
for news in news_list:
print(article_number, end=': ')
print(news.title.text)
print(news.pubDate.text)
if (input('Read (Y or N)? ') == 'y'):
ready = 0
url = news.link.text
article = Article(url)
article.download()
article.parse()
article.nlp()
ready = 1
print('================================================================================================')
print(article.summary)
print('================================================================================================')
article_number = article_number + 1
print("That's all for today!")
if (q == 'Version()'):
print('Python Information Engine CLI Version', end=' ')
print(version)
print('Running Build', end=' ')
print(build)
print('Upon finding a bug, please report to Unsigned_Py and I will try to fix it!')
print('Looking for Python Information Engine CLI Version 1.0 - 1.9?')
print("It's called Wolfram|Alpha and Wikipedia Engine Search!")
if (q != 'Exit()'):
if (q != 'Credits()'):
if (q != 'News'):
if (q != 'Version()'):
ready = 0
search(q)
else:
exitNow = 1
print('Thank you for using Python Information Engine')
print('================================================================================================')
time.sleep(2)
ready = 0
Here's the error:
Traceback (most recent call last):
File "C:\Users\ckyiu\OneDrive\Desktop\Python Information Engine 2.1.py", line 210, in <module>
search(q)
File "C:\Users\ckyiu\OneDrive\Desktop\Python Information Engine 2.1.py", line 62, in search
res = client.query(text)
File "C:\Users\ckyiu\AppData\Local\Programs\Python\Python37-32\lib\site-packages\wolframalpha\__init__.py", line 56, in query
return Result(resp)
File "C:\Users\ckyiu\AppData\Local\Programs\Python\Python37-32\lib\site-packages\wolframalpha\__init__.py", line 178, in __init__
super(Result, self).__init__(doc)
File "C:\Users\ckyiu\AppData\Local\Programs\Python\Python37-32\lib\site-packages\wolframalpha\__init__.py", line 62, in __init__
self._handle_error()
File "C:\Users\ckyiu\AppData\Local\Programs\Python\Python37-32\lib\site-packages\wolframalpha\__init__.py", line 69, in _handle_error
raise Exception(template.format(**self))
Exception: Error 0: Unknown error
Well I got it to work now, for some reason I put: if (q != 'News'): I wanted if (q != 'Latest News'):.
Then python threw me a error for that. I got it to work at least now.