我刚开始在Elm中编程,我正在用vim设置配置,但是遇到了一些麻烦。
我已经下载了elm-vim,但是当我创建一个.elm文件时,我没有语法突出显示,Ale不起作用(它没有显示任何建议/错误)...就像我没有安装elm插件一样。
我安装了以下全局elm软件包:
$ npm list -g | grep elm
├─┬ [email protected]
├─┬ [email protected]
├── [email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
│ ├─┬ [email protected]
│ │ ├─┬ [email protected]
这是我的.vimrc:
set nocompatible
filetype off
filetype plugin on
filetype indent on
set autoread
au FocusGained,BufEnter * checktime
let mapleader=","
set so=7
set showcmd
set wildmenu
set ruler
set backspace=eol,start,indent
set smartcase
set hlsearch
set incsearch
set lazyredraw
set magic
" number + relative number
set number
set relativenumber
" Always display the status line
set laststatus=2
" swap files with unique names in this directory:
set directory=$HOME/Conf/vim/swp//
" No annoying sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
set background=dark
syntax enable
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, tab and indent related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use spaces instead of tabs
set expandtab
" Be smart when using tabs ;)
set smarttab
" 1 tab == 4 spaces
set shiftwidth=4
set tabstop=4
" Linebreak on 500 characters
set lbr
set tw=500
set ai "Auto indent
set si "Smart indent
set wrap "Wrap lines
""""""""""""""""""""""""""""""
" => Visual mode related
""""""""""""""""""""""""""""""
" Visual mode pressing * or # searches for the current selection
" Super useful! From an idea by Michael Naumann
vnoremap <silent> * :<C-u>call VisualSelection('', '')<CR>/<C-R>=@/<CR><CR>
vnoremap <silent> # :<C-u>call VisualSelection('', '')<CR>?<C-R>=@/<CR><CR>
inoremap jj <esc>
nmap ; :
" Smart way to move between windows
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" Copy from vim with CTRL+C
noremap <C-c> "+y
" avoid scanning useless folders
set wildignore+=*/tmp/*,*/node_modules/*,*.so,*.swp,*.zip
function! VisualSelection(direction, extra_filter) range
let l:saved_reg = @"
execute "normal! vgvy"
let l:pattern = escape(@", "\\/.*'$^~[]")
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == 'gv'
call CmdLine("Ack '" . l:pattern . "' " )
elseif a:direction == 'replace'
call CmdLine("%s" . '/'. l:pattern . '/')
endif
let @/ = l:pattern
let @" = l:saved_reg
endfunction
" set the runtime path to include Vundle and initialize
set rtp+=~/Conf/vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim' " required
Plugin 'vim-airline/vim-airline'
Plugin 'pangloss/vim-javascript'
Plugin 'maxmellon/vim-jsx-pretty'
Plugin 'scrooloose/nerdtree'
" NERDTree: shortcut for nerdtree toggle
map <F7> :NERDTreeToggle<CR>
let g:NERDTreeNodeDelimiter = "\u00a0"
" NERDTREE git plugin:
let NERDTreeMinimalUI = 1
let g:NERDTreeIndicatorMapCustom = {
\ "Modified" : "✹",
\ "Staged" : "✚",
\ "Untracked" : "✭",
\ "Renamed" : "➜",
\ "Unmerged" : "═",
\ "Deleted" : "✖",
\ "Dirty" : "✗",
\ "Clean" : "✔︎",
\ 'Ignored' : '☒',
\ "Unknown" : "?"
\ }
Plugin 'valloric/youcompleteme'
Plugin 'dense-analysis/ale'
let g:ale_linters = {
\ 'javascript': ['prettier', 'eslint']
\}
let g:airline#extensions#ale#enabled = 1
Plugin 'elmcast/elm-vim'
call vundle#end() " required
filetype plugin indent on " required
au FileType javascript set sw=2 sts=2 et
au FileType html set sw=4 sts=4 et
au FileType css set sw=4 sts=4 et
au FileType *.py
\ set tabstop=4
\ set softtabstop=4
\ set shiftwidth=4
\ set textwidth=79
\ set expandtab
\ set autoindent
\ set fileformat=unix
我想念什么?
编辑:评论后的更新信息:
:文件类型的输出:
filetype detection:ON plugin:ON indent:ON
:scriptnames的输出
1: /usr/share/vim/vimrc
2: /usr/share/vim/vim81/debian.vim
3: /usr/share/vim/vim81/syntax/syntax.vim
4: /usr/share/vim/vim81/syntax/synload.vim
5: /usr/share/vim/vim81/syntax/syncolor.vim
6: /usr/share/vim/vim81/filetype.vim
7: ~/.vimrc
8: /usr/share/vim/vim81/ftoff.vim
9: /usr/share/vim/vim81/syntax/nosyntax.vim
10: ~/Conf/vim/bundle/Vundle.vim/autoload/vundle.vim
11: ~/Conf/vim/bundle/Vundle.vim/autoload/vundle/config.vim
12: /usr/share/vim/vim81/ftplugin.vim
13: /usr/share/vim/vim81/indent.vim
14: ~/.vim/bundle/vim-airline/plugin/airline.vim
15: ~/.vim/bundle/vim-airline/autoload/airline/init.vim
16: ~/.vim/bundle/vim-airline/autoload/airline/parts.vim
17: ~/.vim/bundle/vim-airline/autoload/airline/util.vim
18: ~/.vim/bundle/nerdtree/plugin/NERD_tree.vim
19: ~/.vim/bundle/nerdtree/autoload/nerdtree.vim
20: ~/.vim/bundle/nerdtree/lib/nerdtree/path.vim
21: ~/.vim/bundle/nerdtree/lib/nerdtree/menu_controller.vim
22: ~/.vim/bundle/nerdtree/lib/nerdtree/menu_item.vim
23: ~/.vim/bundle/nerdtree/lib/nerdtree/key_map.vim
24: ~/.vim/bundle/nerdtree/lib/nerdtree/bookmark.vim
25: ~/.vim/bundle/nerdtree/lib/nerdtree/tree_file_node.vim
26: ~/.vim/bundle/nerdtree/lib/nerdtree/tree_dir_node.vim
27: ~/.vim/bundle/nerdtree/lib/nerdtree/opener.vim
28: ~/.vim/bundle/nerdtree/lib/nerdtree/creator.vim
29: ~/.vim/bundle/nerdtree/lib/nerdtree/flag_set.vim
30: ~/.vim/bundle/nerdtree/lib/nerdtree/nerdtree.vim
31: ~/.vim/bundle/nerdtree/lib/nerdtree/ui.vim
32: ~/.vim/bundle/nerdtree/lib/nerdtree/event.vim
33: ~/.vim/bundle/nerdtree/lib/nerdtree/notifier.vim
34: ~/.vim/bundle/nerdtree/autoload/nerdtree/ui_glue.vim
35: ~/.vim/bundle/nerdtree/nerdtree_plugin/exec_menuitem.vim
36: ~/.vim/bundle/nerdtree/nerdtree_plugin/fs_menu.vim
37: ~/.vim/bundle/nerdtree/nerdtree_plugin/vcs.vim
38: ~/.vim/bundle/elm-vim/plugin/elm.vim
39: ~/.vim/bundle/youcompleteme/plugin/youcompleteme.vim
40: ~/.vim/bundle/ale/plugin/ale.vim
41: ~/.vim/bundle/ale/autoload/ale/events.vim
42: /usr/share/vim/vim81/plugin/getscriptPlugin.vim
43: /usr/share/vim/vim81/plugin/gzip.vim
44: /usr/share/vim/vim81/plugin/logiPat.vim
45: /usr/share/vim/vim81/plugin/manpager.vim
46: /usr/share/vim/vim81/plugin/matchparen.vim
47: /usr/share/vim/vim81/plugin/netrwPlugin.vim
48: /usr/share/vim/vim81/plugin/rrhelper.vim
49: /usr/share/vim/vim81/plugin/spellfile.vim
50: /usr/share/vim/vim81/plugin/tarPlugin.vim
51: /usr/share/vim/vim81/plugin/tohtml.vim
52: /usr/share/vim/vim81/plugin/vimballPlugin.vim
53: /usr/share/vim/vim81/plugin/zipPlugin.vim
54: /usr/share/vim/vim81/scripts.vim
55: ~/.vim/bundle/vim-airline/autoload/airline/extensions.vim
56: ~/.vim/bundle/vim-airline/autoload/airline/extensions/quickfix.vim
57: ~/.vim/bundle/vim-airline/autoload/airline.vim
58: ~/.vim/bundle/vim-airline/autoload/airline/extensions/netrw.vim
59: ~/.vim/bundle/vim-airline/autoload/airline/extensions/term.vim
60: ~/.vim/bundle/vim-airline/autoload/airline/section.vim
61: ~/.vim/bundle/vim-airline/autoload/airline/highlighter.vim
62: ~/.vim/bundle/vim-airline/autoload/airline/extensions/vista.vim
63: ~/.vim/bundle/vim-airline/autoload/airline/extensions/ale.vim
64: ~/.vim/bundle/vim-airline/autoload/airline/extensions/whitespace.vim
65: ~/.vim/bundle/vim-airline/autoload/airline/extensions/wordcount.vim
66: ~/.vim/bundle/vim-airline/autoload/airline/extensions/keymap.vim
67: ~/.vim/bundle/vim-airline/autoload/airline/themes/dark.vim
68: ~/.vim/bundle/vim-airline/autoload/airline/themes.vim
69: ~/.vim/bundle/vim-airline/autoload/airline/builder.vim
70: ~/.vim/bundle/vim-airline/autoload/airline/extensions/default.vim
71: ~/.vim/bundle/ale/autoload/ale.vim
72: ~/.vim/bundle/youcompleteme/autoload/youcompleteme.vim
73: ~/.vim/bundle/ale/autoload/ale/engine.vim
74: ~/.vim/bundle/ale/autoload/ale/statusline.vim
75: ~/.vim/bundle/ale/autoload/ale/cursor.vim
TL; DR:从vimrc文件的顶部删除这些行:
filetype off
filetype plugin on
filetype indent on
应该可以解决问题。
您遇到的问题是,即使成功注册了插件本身,也无法加载将filetype=elm
与*.elm
文件关联的elm-vim的文件类型检测。
Elm中的文件类型检测是通过设置中的~/.vim/bundle/elm-vim/ftdetect/elm.vim
脚本完成的,但从未加载该脚本。
ftdetect
脚本在$VIMRUNTIME/filetype.vim
的执行过程中被加载到Vim中,其中包含this snippet:
" Use the filetype detect plugins. They may overrule any of the previously
" detected filetypes.
runtime! ftdetect/*.vim
filetype.vim
文件作为:filetype on
命令的一部分运行,因此将创建所有autocmd
用于文件类型检测。
但是,filetype.vim
还包括this snippet,这意味着它仅获得一次:
" Listen very carefully, I will say this only once
if exists("did_load_filetypes")
finish
endif
let did_load_filetypes = 1
最终结果是,当您第一次运行filetype.vim
时,:filetype on
仅会获得一次。
这就是为什么Vundle会告诉您在调用filetype plugin indent on
之后立即运行vundle#end()
,因为届时'runtimepath'
将被调整为包括插件路径和插件中的所有ftdetect
目录将被发现。
因此,简而言之,仅使用:filetype
命令之后 Vundle插件安装完成。如果您以前这样做过,则很可能会错过插件的ftdetect
。