From e3a77a5ac0060491d3bef6fca2f54928198e0027 Mon Sep 17 00:00:00 2001 From: dogeystamp Date: Wed, 12 Apr 2023 14:11:57 -0400 Subject: [PATCH] nvim: use Black for code formatting --- programs | 1 + src/.config/nvim/lua/init.lua | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/programs b/programs index 27ce286..334b5ad 100644 --- a/programs +++ b/programs @@ -30,6 +30,7 @@ inkscape scrot pynvim python-lsp-server +python-lsp-black bear xsel xwallpaper diff --git a/src/.config/nvim/lua/init.lua b/src/.config/nvim/lua/init.lua index dedfa37..600bde7 100644 --- a/src/.config/nvim/lua/init.lua +++ b/src/.config/nvim/lua/init.lua @@ -45,6 +45,7 @@ local on_attach = function(client, bufnr) buf_set_keymap('n', '[d', 'lua vim.lsp.diagnostic.goto_prev()', opts) buf_set_keymap('n', ']d', 'lua vim.lsp.diagnostic.goto_next()', opts) buf_set_keymap('n', 'ca', 'lua vim.lsp.buf.code_action()', opts) + buf_set_keymap('n', 'f', 'lua vim.lsp.buf.format()', opts) end -- settings per server (overrides defaults) @@ -57,6 +58,9 @@ local servers = { enabled = true, convention = "numpy", addIgnore = {"D100", "D101", "D102", "D105"} + }, + black = { + enabled = true, } } } @@ -72,8 +76,8 @@ for lsp, sv_settings in pairs(servers) do debounce_text_changes = 150, } } - for k, v in pairs(servers) do settings[k] = v end - nvim_lsp[lsp].setup(settings[lsp]) + for k, v in pairs(servers[lsp]) do settings[k] = v end + nvim_lsp[lsp].setup(settings) end -- fancy prompts