惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Stack Overflow Blog
Stack Overflow Blog
L
LangChain Blog
人人都是产品经理
人人都是产品经理
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Tailwind CSS Blog
N
Netflix TechBlog - Medium
Microsoft Security Blog
Microsoft Security Blog
J
Java Code Geeks
博客园 - 【当耐特】
量子位
有赞技术团队
有赞技术团队
Jina AI
Jina AI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园_首页
C
Check Point Blog
B
Blog RSS Feed
M
MIT News - Artificial intelligence
H
Help Net Security
雷峰网
雷峰网
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 聂微东
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
A
About on SuperTechFans
腾讯CDC

依云's Blog

Wayfire支持不缩放Xwayland啦 - 依云's Blog 使用wayvnc远程访问无头Wayfire会话 - 依云's Blog pacfiles: 高速的 pacman -F 替代品 用 Android 手机当电脑的话筒 - 依云's Blog 使用 ffmpeg 对音频文件进行响度归一化 - 依云's Blog 使用 nftables 屏蔽大量 IP - 依云's Blog YubiKey 初体验 - 依云's Blog fcitx5 码表同步方案 - 依云's Blog 我正在使用的火狐扩展(2024年版) - 依云's Blog 使用 PipeWire 实现自动应用均衡器 如果你发现你的 OOM Killer 在乱杀进程 使用 atuin 管理 shell 命令历史 btrfs 元数据满了怎么办 btrfs 翻车记 在 nspawn 里运行 docker Linux 上的字体配置与故障排除 新的 PaddleOCR 部署方案 使用 EasyEffects 调整 Bose 音箱的体验 让离线软件真正离线 我所讨厌的网页行为 tmux 状态栏优化 Google Chrome 中的字体设置 从 getmail6 到 offlineimap 微信消息通知的困扰 Qt 的字体渲染问题 Wayfire 迁移进展(四):不那么 high 的 DPI Wayfire 迁移进展(二):Xwayland HiDPI 以及 waybar Wayfire 迁移进展 不同情况下的图形效果 Wayland 初体验
neocomplcache: 请尊重大小写!
依云 · 2012-01-03 · via 依云's Blog

今天给 Vim 加了个 CursorHold 事件。加完提交到 git 仓库中,发现写 Cur 时,neocomplcache 给出的补全是 Cursorhold,而不是代码中写的 CursorHold,得手动改过来,很郁闷。这已经不是我第一次遇到了,决定需求解决方案。

neocomplcache 关于大小写的设置变量有两个,g:neocomplcache_enable_ignore_caseg:neocomplcache_enable_smart_case。这两个我都没有设置啊。以为是 bug,上网搜索无果,遂看源码,最终发现这真是款自作聪明的插件——在输入文本而不是代码时,它将总是忽略大小写!

补丁如下:

commit aaed422a2dff182954813c16db242545389a0018
Author: 依云 <lilydjwg@gmail.com>
Date:   2012-01-03 23:01:43 +0800

    neocomplcache: never use 'is_text_mode'
    
    This always causes inconvenience for me.

diff --git a/autoload/neocomplcache.vim b/autoload/neocomplcache.vim
index 26a2d09..ac1e0f0 100644
--- a/autoload/neocomplcache.vim
+++ b/autoload/neocomplcache.vim
@@ -995,9 +995,6 @@ endfunction"}}}
 function! neocomplcache#is_eskk_enabled()"{{{
   return exists('*eskk#is_enabled') && eskk#is_enabled()
 endfunction"}}}
-function! neocomplcache#is_text_mode()"{{{
-  return s:is_text_mode || s:within_comment
-endfunction"}}}
 function! neocomplcache#is_win()"{{{
   return has('win32') || has('win64')
 endfunction"}}}
@@ -1135,9 +1132,7 @@ function! neocomplcache#get_complete_result(cur_text, ...)"{{{
       " Save options.
       let l:ignorecase_save = &ignorecase
 
-      if neocomplcache#is_text_mode()
-        let &ignorecase = 1
-      elseif g:neocomplcache_enable_smart_case && l:cur_keyword_str =~ '\u'
+      if g:neocomplcache_enable_smart_case && l:cur_keyword_str =~ '\u'
         let &ignorecase = 0
       else
         let &ignorecase = g:neocomplcache_enable_ignore_case
@@ -1289,26 +1284,6 @@ function! neocomplcache#integrate_completion(complete_result, is_sort)"{{{
     endfor
   endif"}}}
 
-  " Convert words.
-  if neocomplcache#is_text_mode()"{{{
-    if l:cur_keyword_str =~ '^\l\+$'
-      for l:keyword in l:complete_words
-        let l:keyword.word = tolower(l:keyword.word)
-        let l:keyword.abbr = tolower(l:keyword.abbr)
-      endfor
-    elseif l:cur_keyword_str =~ '^\u\+$'
-      for l:keyword in l:complete_words
-        let l:keyword.word = toupper(l:keyword.word)
-        let l:keyword.abbr = toupper(l:keyword.abbr)
-      endfor
-    elseif l:cur_keyword_str =~ '^\u\l\+$'
-      for l:keyword in l:complete_words
-        let l:keyword.word = toupper(l:keyword.word[0]).tolower(l:keyword.word[1:])
-        let l:keyword.abbr = toupper(l:keyword.abbr[0]).tolower(l:keyword.abbr[1:])
-      endfor
-    endif
-  endif"}}}
-
   if g:neocomplcache_max_keyword_width >= 0"{{{
     " Abbr check.
     let l:abbr_pattern = printf('%%.%ds..%%s', g:neocomplcache_max_keyword_width-15)
@@ -1671,9 +1646,7 @@ function! neocomplcache#complete_common_string()"{{{
   " Get cursor word.
   let [l:cur_keyword_pos, l:cur_keyword_str] = neocomplcache#match_word(s:get_cur_text())
 
-  if neocomplcache#is_text_mode()
-    let &ignorecase = 1
-  elseif g:neocomplcache_enable_smart_case && l:cur_keyword_str =~ '\u'
+  if g:neocomplcache_enable_smart_case && l:cur_keyword_str =~ '\u'
     let &ignorecase = 0
   else
     let &ignorecase = g:neocomplcache_enable_ignore_case
@@ -1771,9 +1744,7 @@ function! s:make_quick_match_list(list, cur_keyword_str)"{{{
   " Save options.
   let l:ignorecase_save = &ignorecase
 
-  if neocomplcache#is_text_mode()
-    let &ignorecase = 1
-  elseif g:neocomplcache_enable_smart_case && a:cur_keyword_str =~ '\u'
+  if g:neocomplcache_enable_smart_case && a:cur_keyword_str =~ '\u'
     let &ignorecase = 0
   else
     let &ignorecase = g:neocomplcache_enable_ignore_case
diff --git a/autoload/neocomplcache/sources/dictionary_complete.vim b/autoload/neocomplcache/sources/dictionary_complete.vim
index 97e7b12..dda34be 100644
--- a/autoload/neocomplcache/sources/dictionary_complete.vim
+++ b/autoload/neocomplcache/sources/dictionary_complete.vim
@@ -79,11 +79,7 @@ endfunction"}}}
 function! s:source.get_keyword_list(cur_keyword_str)"{{{
   let l:list = []
 
-  let l:filetype = neocomplcache#is_text_mode() ? 'text' : neocomplcache#get_context_filetype()
-  if neocomplcache#is_text_mode() && !has_key(s:dictionary_list, 'text')
-    " Caching.
-    call s:caching()
-  endif
+  let l:filetype = neocomplcache#get_context_filetype()
 
   for l:ft in neocomplcache#get_source_filetypes(l:filetype)
     call neocomplcache#cache#check_cache('dictionary_cache', l:ft, s:async_dictionary_list,
@@ -102,7 +98,7 @@ function! s:caching()"{{{
     return
   endif
 
-  let l:key = neocomplcache#is_text_mode() ? 'text' : neocomplcache#get_context_filetype()
+  let l:key = neocomplcache#get_context_filetype()
   for l:filetype in neocomplcache#get_source_filetypes(l:key)
     if !has_key(s:dictionary_list, l:filetype)
           \ && !has_key(s:async_dictionary_list, l:filetype)

2012年3月30日更新:针对 neocomplcache 6.2 的补丁在此

2013年6月2日更新:针对 neocomplcache 8.0 的补丁在这里或者这里。对应的 git 提交为 17dd164。