Add python black and isort as LSP formatter using EFM
This commit is contained in:
parent
65f7631912
commit
0be716be4f
|
@ -29,7 +29,9 @@ local on_attach = function(client, bufnr)
|
||||||
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, bufopts)
|
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, bufopts)
|
||||||
vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, bufopts)
|
vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, bufopts)
|
||||||
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
|
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
|
||||||
vim.keymap.set('n', '<leader>i', vim.lsp.buf.formatting, bufopts)
|
vim.keymap.set('n', '<leader>i', function ()
|
||||||
|
vim.lsp.buf.format({timeout_ms=10000,async=false}) -- async=true is strange behavior
|
||||||
|
end, bufopts)
|
||||||
-- Enable aerial support
|
-- Enable aerial support
|
||||||
require("aerial").on_attach(client, bufnr)
|
require("aerial").on_attach(client, bufnr)
|
||||||
end
|
end
|
||||||
|
@ -136,6 +138,19 @@ elseif file_exists(pylsp_file) then
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
require('lspconfig')['efm'].setup{
|
||||||
|
init_options = {documentFormatting = true},
|
||||||
|
settings = {
|
||||||
|
languages = {
|
||||||
|
python = {
|
||||||
|
{formatCommand = 'black --quiet -', formatStdin = true},
|
||||||
|
{formatCommand = 'isort --quiet -', formatStdin = true},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
filetypes = {'python'},
|
||||||
|
}
|
||||||
|
|
||||||
require('lspconfig')['fortls'].setup{
|
require('lspconfig')['fortls'].setup{
|
||||||
cmd = {os.getenv( "HOME" ).."/.pyenv/versions/neovim3/bin/fortls"},
|
cmd = {os.getenv( "HOME" ).."/.pyenv/versions/neovim3/bin/fortls"},
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
|
|
|
@ -17,7 +17,6 @@ nmap('<leader>sr', ':SnipRun<cr>')
|
||||||
nmap('<leader>gf', ':Git fetch<cr>')
|
nmap('<leader>gf', ':Git fetch<cr>')
|
||||||
nmap('<leader>gp', ':Git pull<cr>')
|
nmap('<leader>gp', ':Git pull<cr>')
|
||||||
nmap('<leader>gP', ':Git push<cr>')
|
nmap('<leader>gP', ':Git push<cr>')
|
||||||
nmap('<leader>i', ':!black % ; zimports %<cr>')
|
|
||||||
|
|
||||||
-- Telescope
|
-- Telescope
|
||||||
nmap('<leader>;', '<cmd>Telescope builtin<cr>')
|
nmap('<leader>;', '<cmd>Telescope builtin<cr>')
|
||||||
|
|
Loading…
Reference in a new issue