I want to write some JavaScript code inside an HTML file using <script></script>
, but I get wrong indentation when using o
for insert a new line.
Here is what I want:
<script type="text/javascript">
function sumNumbers(num1, num2) {
return num1 + num2;
}
</script>
And here is what I get:
<script type="text/javascript">
function sumNumbers(num1, num2) {
return num1 + num2;
}
</script>
Maybe there are two different options enabled for indentation.
I'm using sheerun/vim-polyglot
, and I think it's the only plugin doing indentation.
I'm using Neovim. Here is my init.vim
:
call plug#begin('~/.local/share/nvim/plugged')
Plug 'sheerun/vim-polyglot'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'morhetz/gruvbox'
Plug 'dracula/vim'
Plug 'scrooloose/nerdtree'
Plug 'ryanoasis/vim-devicons'
Plug 'maximbaz/lightline-ale'
Plug 'itchyny/lightline.vim'
Plug 'yggdroot/indentline'
Plug 'mattn/emmet-vim'
Plug 'AndrewRadev/tagalong.vim'
call plug#end()
set encoding=UTF-8
set number
set scrolloff=8
set timeoutlen=300
filetype plugin on
syntax enable
colorscheme dracula
highlight Normal ctermbg=233
set cursorline
highlight CursorLine ctermbg=235
set hlsearch
set incsearch
set ignorecase
set smartcase
let g:indentLine_char = '|'
let g:NERDTreeShowHidden = 1
let g:NERDTreeMinimalUI = 1
let g:NERDTreeIgnore = []
let g:NERDTreeStatusline = ''
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
nnoremap <silent> <C-n> :NERDTreeToggle<CR>
let g:user_emmet_leader_key=','
let g:user_emmet_install_global=0
autocmd FileType html,css EmmetInstall
tnoremap <Esc> <C-\><C-n>
tnoremap <A-[> <Esc>
tnoremap <A-h> <C-\><C-n><C-w>h
tnoremap <A-j> <C-\><C-n><C-w>j
tnoremap <A-k> <C-\><C-n><C-w>k
tnoremap <A-l> <C-\><C-n><C-w>l
nnoremap <A-h> <C-w>h
nnoremap <A-j> <C-w>j
nnoremap <A-k> <C-w>k
nnoremap <A-l> <C-w>l
let g:coc_global_extensions = ['coc-emmet', 'coc-css', 'coc-html', 'coc-json', 'coc-prettier', 'coc-tsserver', 'coc-eslint']
nmap <C-s> :w<CR>
imap <C-s> <Esc>:w<CR>
Is there a way to know what is going on?
In your coc-settings.json
file, there is a way to add certain filetypes that will be formatted on save. Maybe that will help.
{
"coc.preferences.formatOnSaveFiletypes": [
"javascript"
]
}