fix autoformatting on save

This commit is contained in:
Ray Elliott 2021-10-05 23:16:48 +01:00
parent 5bad300475
commit b6842faf9e
4 changed files with 191 additions and 20 deletions

149
Session.ts.vim Normal file
View File

@ -0,0 +1,149 @@
let SessionLoad = 1
let s:so_save = &g:so | let s:siso_save = &g:siso | setg so=0 siso=0 | setl so=-1 siso=-1
let v:this_session=expand("<sfile>:p")
silent only
silent tabonly
cd ~/.config/nvim
if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == ''
let s:wipebuf = bufnr('%')
endif
set shortmess=aoO
badd +36 init.tabline.vim
badd +22 init.auto-window.vim
badd +1 coc-settings.json
badd +184 init.vim
badd +1 ftplugin/php.vim
badd +2 after/ftplugin/php.vim
badd +1 after/ftplugin/html.vim
badd +1 after/ftplugin/javascript.vim
badd +8 after/ftplugin/python.vim
badd +1 after/ftplugin/sass.vim
badd +1 after/ftplugin/vim.vim
badd +1 ftplugin/vue.vim
badd +1 ftplugin/sass.vim
badd +1 ftplugin/javascript.vim
badd +1 ftplugin/css.vim
badd +50 init.plugins.vim
badd +1 after/indent/php.vim
badd +10 init.commands.vim
badd +7 lua/init-plugins.lua
badd +1 after/queries/ecma/highlights.scm
badd +16 after/queries/html/highlights.scm
badd +2 after/queries/css/highlights.scm
argglobal
%argdel
$argadd init.tabline.vim
edit after/queries/css/highlights.scm
let s:save_splitbelow = &splitbelow
let s:save_splitright = &splitright
set splitbelow splitright
wincmd _ | wincmd |
vsplit
1wincmd h
wincmd _ | wincmd |
split
1wincmd k
wincmd w
wincmd w
let &splitbelow = s:save_splitbelow
let &splitright = s:save_splitright
wincmd t
let s:save_winminheight = &winminheight
let s:save_winminwidth = &winminwidth
set winminheight=0
set winheight=1
set winminwidth=0
set winwidth=1
exe '1resize ' . ((&lines * 22 + 25) / 50)
exe 'vert 1resize ' . ((&columns * 103 + 105) / 211)
exe '2resize ' . ((&lines * 22 + 25) / 50)
exe 'vert 2resize ' . ((&columns * 103 + 105) / 211)
exe 'vert 3resize ' . ((&columns * 107 + 105) / 211)
argglobal
balt after/queries/html/highlights.scm
setlocal fdm=indent
setlocal fde=0
setlocal fmr={{{,}}}
setlocal fdi=#
setlocal fdl=99
setlocal fml=1
setlocal fdn=9
setlocal fen
let s:l = 3 - ((2 * winheight(0) + 11) / 22)
if s:l < 1 | let s:l = 1 | endif
keepjumps exe s:l
normal! zt
keepjumps 3
normal! 023|
lcd ~/.config/nvim
wincmd w
argglobal
if bufexists("/usr/share/nvim/runtime/doc/treesitter.txt") | buffer /usr/share/nvim/runtime/doc/treesitter.txt | else | edit /usr/share/nvim/runtime/doc/treesitter.txt | endif
if &buftype ==# 'terminal'
silent file /usr/share/nvim/runtime/doc/treesitter.txt
endif
setlocal fdm=manual
setlocal fde=0
setlocal fmr={{{,}}}
setlocal fdi=#
setlocal fdl=99
setlocal fml=1
setlocal fdn=9
setlocal nofen
silent! normal! zE
let &fdl = &fdl
let s:l = 196 - ((5 * winheight(0) + 11) / 22)
if s:l < 1 | let s:l = 1 | endif
keepjumps exe s:l
normal! zt
keepjumps 196
normal! 050|
lcd ~/.config/nvim
wincmd w
argglobal
if bufexists("~/.config/nvim/after/indent/php.vim") | buffer ~/.config/nvim/after/indent/php.vim | else | edit ~/.config/nvim/after/indent/php.vim | endif
if &buftype ==# 'terminal'
silent file ~/.config/nvim/after/indent/php.vim
endif
setlocal fdm=marker
setlocal fde=0
setlocal fmr={{{,}}}
setlocal fdi=#
setlocal fdl=99
setlocal fml=1
setlocal fdn=9
setlocal fen
let s:l = 4 - ((3 * winheight(0) + 22) / 45)
if s:l < 1 | let s:l = 1 | endif
keepjumps exe s:l
normal! zt
keepjumps 4
normal! 03|
lcd ~/.config/nvim
wincmd w
exe '1resize ' . ((&lines * 22 + 25) / 50)
exe 'vert 1resize ' . ((&columns * 103 + 105) / 211)
exe '2resize ' . ((&lines * 22 + 25) / 50)
exe 'vert 2resize ' . ((&columns * 103 + 105) / 211)
exe 'vert 3resize ' . ((&columns * 107 + 105) / 211)
if exists(':tcd') == 2 | tcd ~/.config/nvim | endif
tabnext 1
if exists('s:wipebuf') && len(win_findbuf(s:wipebuf)) == 0&& getbufvar(s:wipebuf, '&buftype') isnot# 'terminal'
silent exe 'bwipe ' . s:wipebuf
endif
unlet! s:wipebuf
set winheight=1 winwidth=20 shortmess=aoOT
let &winminheight = s:save_winminheight
let &winminwidth = s:save_winminwidth
let s:sx = expand("<sfile>:p:r")."x.vim"
if filereadable(s:sx)
exe "source " . fnameescape(s:sx)
endif
let &g:so = s:so_save | let &g:siso = s:siso_save
set hlsearch
let g:this_session = v:this_session
let g:this_obsession = v:this_session
let g:this_obsession_status = 2
doautoall SessionLoadPost
unlet SessionLoad
" vim: set ft=vim :

View File

@ -33,7 +33,7 @@ cmp.setup({
sources = { sources = {
{ {
name = 'nvim_lsp', name = 'nvim_lsp',
max_item_count = 20, max_item_count = 8,
}, },
{ name = 'path' }, { name = 'path' },
{ {

View File

@ -40,12 +40,12 @@ local luaformat = {
} }
local util = require "lspconfig".util local util = require "lspconfig".util
local on_attach_efm = function(client) local on_attach_efm = function(client)
-- if client.resolved_capabilities.document_formatting then if client.resolved_capabilities.document_formatting then
-- vim.cmd [[augroup lsp_formatting]] vim.cmd [[augroup efm_formatting]]
-- vim.cmd [[autocmd!]] vim.cmd [[autocmd!]]
-- vim.cmd [[autocmd BufWritePre <buffer> :lua vim.lsp.buf.formatting_seq_sync({}, 1000)]] vim.cmd [[autocmd BufWritePre <buffer> :lua vim.lsp.buf.formatting_seq_sync({}, 1000)]]
-- vim.cmd [[augroup END]] vim.cmd [[augroup END]]
-- end end
end end
require "lspconfig".efm.setup { require "lspconfig".efm.setup {
init_options = {documentFormatting = true}, init_options = {documentFormatting = true},

View File

@ -14,8 +14,6 @@ local servers = {
'phpactor', 'phpactor',
-- npm install -g pyright -- npm install -g pyright
'pyright', 'pyright',
-- npm i -g stylelint-lsp
'stylelint_lsp',
-- https://github.com/neovim/nvim-lspconfig/wiki -- https://github.com/neovim/nvim-lspconfig/wiki
-- 'tailwindcss', -- 'tailwindcss',
-- npm install -g typescript typescript-language-server -- npm install -g typescript typescript-language-server
@ -55,9 +53,17 @@ local on_attach = function(client, bufnr)
-- buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts) -- buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
-- buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts) -- buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
-- buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts) -- buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
if client.resolved_capabilities.document_formatting then
vim.cmd [[augroup lsp_formatting]]
vim.cmd [[autocmd!]]
vim.cmd [[autocmd BufWritePre <buffer> :lua vim.lsp.buf.formatting_seq_sync({}, 1000)]]
vim.cmd [[augroup END]]
end
end end
local capabilities = vim.lsp.protocol.make_client_capabilities() local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
capabilities.textDocument.completion.completionItem.snippetSupport = true capabilities.textDocument.completion.completionItem.snippetSupport = true
for _, lsp in ipairs(servers) do for _, lsp in ipairs(servers) do
@ -69,3 +75,19 @@ for _, lsp in ipairs(servers) do
} }
} }
end end
-- npm i -g stylelint-lsp
nvim_lsp.stylelint_lsp.setup {
on_attach = on_attach,
capabilities = capabilities,
flags = {
debounce_text_changes = 150,
},
filetypes = {'css', 'scss', 'less'},
settings = {
stylelintplus = {
autoFixOnSave = true,
autoFixOnFormat = true,
}
}
}