nvim: autoformat code using lsp-format
also don't autoformat code like text
This commit is contained in:
parent
82575e320d
commit
16226f0a7d
|
@ -48,6 +48,11 @@ local on_attach = function(client, bufnr)
|
|||
buffer = bufnr,
|
||||
callback = vim.lsp.buf.clear_references,
|
||||
})
|
||||
|
||||
-- Don't autoformat code like text
|
||||
vim.bo.formatoptions = vim.o.formatoptions:gsub('t', '')
|
||||
-- Let LSP autoformat on save
|
||||
require('lsp-format').on_attach(client)
|
||||
end
|
||||
|
||||
-- -- show help on hover -- cursor ends up in popup
|
||||
|
@ -161,3 +166,7 @@ if vim.fn.executable('vscode-json-language-server') > 0 then
|
|||
capabilities = capabilities
|
||||
}
|
||||
end
|
||||
|
||||
require("lsp-format").setup({
|
||||
sync = true -- seems to be needed to not interfere with Neogit
|
||||
})
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
local install_path = vim.fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
|
||||
local install_path = vim.fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim'
|
||||
local packer_bootstrap
|
||||
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
|
||||
packer_bootstrap = vim.fn.system({
|
||||
'git',
|
||||
'clone',
|
||||
'https://github.com/wbthomason/packer.nvim',
|
||||
install_path})
|
||||
install_path
|
||||
})
|
||||
vim.cmd [[packadd packer.nvim]]
|
||||
end
|
||||
|
||||
|
@ -57,6 +58,10 @@ require('packer').startup(function(use)
|
|||
tag = '*',
|
||||
requires = 'https://github.com/hrsh7th/cmp-nvim-lsp'
|
||||
}
|
||||
use {
|
||||
'https://github.com/lukas-reineke/lsp-format.nvim',
|
||||
tag = '*'
|
||||
}
|
||||
|
||||
-- tools
|
||||
use {
|
||||
|
@ -99,7 +104,7 @@ require('packer').startup(function(use)
|
|||
use { 'https://github.com/gentoo/gentoo-syntax' }
|
||||
use {
|
||||
'https://github.com/windwp/nvim-autopairs',
|
||||
config = function() require("nvim-autopairs").setup{} end
|
||||
config = function() require("nvim-autopairs").setup {} end
|
||||
}
|
||||
use { 'https://github.com/L3MON4D3/LuaSnip' }
|
||||
use {
|
||||
|
@ -112,7 +117,7 @@ require('packer').startup(function(use)
|
|||
}
|
||||
|
||||
-- net
|
||||
use { -- embed nvim in browsers
|
||||
use { -- embed nvim in browsers
|
||||
'https://github.com/glacambre/firenvim',
|
||||
tag = '*',
|
||||
run = function()
|
||||
|
@ -135,7 +140,7 @@ vim.api.nvim_create_autocmd(
|
|||
{
|
||||
group = 'config_plugins',
|
||||
pattern = { vim.fn.stdpath('config') .. '/lua/my/plugins.lua' },
|
||||
command =[[source <afile> | PackerInstall]]
|
||||
command = [[source <afile> | PackerInstall]]
|
||||
}
|
||||
)
|
||||
vim.api.nvim_create_autocmd(
|
||||
|
|
Loading…
Reference in New Issue
Block a user