= array();
}
$post['classname'] = 'post';
}
function comment_format(&$post)
{
global $conf, $uid, $gid, $forumlist;
if (empty($post)) return;
$forum = $post['fid'] ? forum_read($post['fid']) : '';
$thread = well_thread_read_cache($post['tid']);
if ($thread) {
//$post['fid'] = $thread['fid'];
$post['closed'] = $thread['closed'];
$post['subject'] = $thread['subject'];
$post['url'] = $thread['url'];
} else {
$post['closed'] = 0;
$post['subject'] = lang('thread_not_exists');
$post['url'] = '';
}
$post['create_date_fmt'] = humandate($post['create_date']);
//$post['message'] = stripslashes(htmlspecialchars_decode($post['message']));
$user = user_read_cache($post['uid']);
$post['username'] = array_value($user, 'username');
$post['user_avatar_url'] = array_value($user, 'avatar_url');
$post['user'] = $user ? user_safe_info($user) : user_guest();
isset($post['floor']) || $post['floor'] = 0;
// 权限判断
$post['allowupdate'] = 2 == array_value($forum, 'comment', 0) && ($uid == $post['uid'] || forum_access_mod($post['fid'], $gid, 'allowupdate'));
$post['allowdelete'] = group_access($gid, 'allowuserdelete') && $uid == $post['uid'] || forum_access_mod($post['fid'], $gid, 'allowdelete');
$post['user_url'] = url('user-' . $post['uid'] . ($post['uid'] ? '' : '-' . $post['pid']));
if ($post['files'] > 0) {
list($attachlist, $imagelist, $filelist) = well_attach_find_by_pid($post['pid']);
// 使用图床 评论使用图床,mysql会过多,写死链接到内容是减轻mysql的过多的方法
if (2 == $conf['attach_on']) {
foreach ($imagelist as $key => $attach) {
$url = $conf['upload_url'] . 'website_attach/' . $attach['filename'];
// 替换成图床
$post['message'] = FALSE !== strpos($post['message'], $url) && $attach['image_url'] ? str_replace($url, $attach['image_url'], $post['message']) : $post['message'];
}
}
$post['filelist'] = $filelist;
} else {
$post['filelist'] = array();
}
$post['classname'] = 'post';
}
function comment_format_message(&$val)
{
global $conf;
if (empty($val)) return;
// 使用云储存
if (1 == $conf['attach_on'] && 1 == $val['attach_on']) {
$val['message'] = str_replace('="upload/', '="' . file_path($val['attach_on']), $val['message']);
} elseif (2 == $conf['attach_on'] && 2 == $val['attach_on']) {
// 使用图床
list($attachlist, $imagelist, $filelist) = well_attach_find_by_tid($val['tid']);
foreach ($imagelist as $key => $attach) {
$url = $conf['upload_url'] . 'website_attach/' . $attach['filename'];
// 替换成图床
$val['message'] = FALSE !== strpos($val['message'], $url) && $attach['image_url'] ? str_replace($url, $attach['image_url'], $val['message']) : $val['message'];
}
} else {
$val['message'] = str_replace('="upload/', '="' . file_path($val['attach_on']), $val['message']);
}
//$val['message'] = stripslashes(htmlspecialchars_decode($val['message']));
}
// 把内容中使用了云储存的附件链接替换掉
function comment_message_replace_url($pid, $message)
{
global $conf;
if (0 == $conf['attach_on']) {
$message = FALSE !== strpos($message, '="../upload/') ? str_replace('="../upload/', '="upload/', $message) : $message;
$message = FALSE !== strpos($message, '="/upload/') ? str_replace('="/upload/', '="upload/', $message) : $message;
} elseif (1 == $conf['attach_on']) {
// 使用云储存
$message = str_replace('="' . $conf['cloud_url'] . 'upload/', '="upload/', $message);
} elseif (2 == $conf['attach_on']) {
// 使用图床 评论使用图床,mysql会过多,写死链接到内容是减轻mysql的过多的方法
list($attachlist, $imagelist, $filelist) = well_attach_find_by_pid($pid);
foreach ($imagelist as $key => $attach) {
$url = $conf['upload_url'] . 'website_attach/' . $attach['filename'];
// 替换回相对链接
$message = $attach['image_url'] && FALSE !== strpos($message, $attach['image_url']) ? str_replace($attach['image_url'], $url, $message) : $message;
}
}
return $message;
}
function comment_filter($val)
{
unset($val['userip']);
return $val;
}
function comment_highlight_keyword($str, $k)
{
$r = str_ireplace($k, '' . $k . ' ', $str);
return $r;
}
//
//
function comment_message_format(&$s)
{
if (xn_strlen($s) < 100) return;
$s = preg_replace('#.*? #is', '', $s);
$s = str_ireplace(array(' ', ' ', ' ', '', '', '', '', '' . ''), "\r\n", $s);
$s = str_ireplace(array(' '), " ", $s);
$s = strip_tags($s);
$s = preg_replace('#[\r\n]+#', "\n", $s);
$s = xn_substr(trim($s), 0, 100);
$s = str_replace("\n", ' ', $s);
}
// 对内容进行引用
function comment_quote($quotepid)
{
$quotepost = comment_read($quotepid);
if (empty($quotepost)) return '';
$uid = $quotepost['uid'];
$s = $quotepost['message'];
$s = comment_brief($s, 100);
$userhref = url('user-' . $uid);
$user = user_read_cache($uid);
$r = '
' . $user['username'] . '
' . $s . '
';
return $r;
}
// 获取内容的简介 0: html, 1: txt; 2: markdown; 3: ubb
function comment_brief($s, $len = 100)
{
$s = strip_tags($s);
$s = htmlspecialchars($s);
$more = xn_strlen($s) > $len ? ' ... ' : '';
$s = xn_substr($s, 0, $len) . $more;
return $s;
}
?>在win7或win10上安装neovim并配置gvim(nvim-qt) 你的位置:
首页 > 运维笔记 > 在win7或win10上安装neovim并配置gvim(nvim-qt)
在win7或win10上安装neovim并配置gvim(nvim-qt)
由于gvim8.2在win7和win10上安装好后,不能正常使用插件NERDTree(只对当前目录和文件有效,对下一级目录没有反应),尝试在win10的wsl上安装Ubuntu后编译安装vim8.2,结果NERDTree插件能够正常使用,心想是否是gvim软件本身有问题,考虑在winows系统中安装neovim,结果成功了。
下载和解压neovim
先在 neovim下载页面https://github/neovim/neovim/releases/nightly 找到 nvim-win64.zip(32位或64位) ,下载到本地。 解压到一个目录,例如 c:\Neovim。 把 c:\Neovim\bin添加到操作系统的路径中。以便于通过win10中terminal 或 cmd中可以启动nvim。但是在win7中使用不方便,因为命令窗口Tui不能全屏。 把该目录中的nvim-qt.exe(相当于gvim)文件发送快捷键到桌面。这样在win7和win10中使用都比较方便。
配置并解决出现的问题
相当于vim中的配置文件即 ~\vimfiles 中的文件 vimrc 和 gvimrc,在neovim中,则在 ~\AppData\Local\中先创建目录 nvim ,对应的配置文件为: init.vim和ginit.vim。 如果需要安装插件,推荐使用 vim-plug https://github/junegunn/vim-plug,最终是在 ~\AppData\Local\nivm\autoload (需要手动创建autoload目录)中把那个网页中文件 plug.vim 放入其中。 在 init.vim 配置文件中输入
call plug#begin('~/AppData/Local/nvim/plugged')`
"中间加入一些插件,例如
" Shorthand notation; fetches https://github/junegunn/vim-easy-align
Plug 'junegunn/vim-easy-align'
Plug 'tpope/vim-vinegar'
" file navigation
Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'vim-airline/vim-airline'
" fuzzy file finder
Plug 'kien/ctrlp.vim'
Plug 'atweiden/vim-dragvisuals'
Plug 'gavocanov/foldsearches.vim'
" coc.nvim
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" git tool
Plug 'tpope/vim-fugitive'
" Visual content can move
Plug 'atweiden/vim-dragvisuals'
" Vim global plugin for persistent Visual seletions
Plug 'galli-a/persistentvisuals'
" syntax check/linter
Plug 'vim-syntastic/syntastic'
" surround
Plug 'tpope/vim-surround'
" vim-commentary
Plug 'tpope/vim-commentary'
" emmet
Plug 'mattn/emmet-vim'
" easymotion
Plug 'easymotion/vim-easymotion'
" code debug
Plug 'puremourning/vimspector'
call plug#end()`
如果需要安装coc插件,则需要python2和pythone3,并且需要进行配置,否则在启动nvim-qt.exe时,出现一个错误提示: [coc.nvim] Error on execute python script: … ,在输入 :checkhealth provider 后出现 Python 3 provider (optional) WARNING: No Python executable found that can import neovim
等,则表示需要安装python2和python3, 在win10中安装了python-3.8.6和python-2.7.18到 c:\python3 和 c:\python2目录下,然后再启动仍然有警告,再次 :checkhealth provider 后,列举其中一句: ~\AppData\Local\Programs\Python\Python38\python.EXE does not have the “neovim” module. :help provider-python, 键入 :h provider-python,可以查找帮助,但是使用帮助文档中推荐的命令是: python3 -m pip install --user --upgrade pynvim 和 python -m pip install --user --upgrade pynvim, 在win系统命令行窗口中运行不成功,而运行以下命令可以:
c: \python3\python - m pip install - - user - - upgrade pynvim
c: \python2\python - m pip install - - user - - upgrade pynvim
最后在配置文件 init.vim 中添加两行:
let g:python_host_prog = 'C:\Python2\python.exe'
let g:python3_host_prog = 'C:\Python3\python.exe'
安装插件 coc.nvim 需要安装node,例如: node-v12.19.0-x64.msi。并在操作系统的终端或cmd中执行:
npm install -g neovim
提示script_host.py有编码问题 在以下目录中找到文件: $HOME\AppData\Roaming\Python\Python38\site-packages\pynvim\plugin\script_host.py文件,把第107行从 with open(file_path) as f:
改为 with open(file_path, encoding='utf-8') as f:
以下是在win10 的wsl2中安装Ubuntu, 及nvim后要解决问题: 8.安装perl和cpanm比较麻烦。先安装perl,然后安装cpanmius,最后需要在expert export PERL_CPANM_OPT=“–prompt --reinstall -l ~/perl --mirror http://cpan.cpantesters” 把这行写入 .bashrc 中。
鼠标右键快捷菜单中添加nvim-qt
参考这个 win10 自定义右键菜单