Added Format command to nvim

This commit is contained in:
_N0x 2022-02-24 19:42:49 +01:00
parent 5ff77c5bf3
commit d860d44f44
2 changed files with 26 additions and 4 deletions

View File

@ -27,10 +27,10 @@ keymap("n", "<C-+>", "<C-}>", opts)
-- Normal --
-- Better window navigation
keymap("n", "<C-h>", "<C-w>h", opts)
keymap("n", "<C-j>", "<C-w>j", opts)
keymap("n", "<C-k>", "<C-w>k", opts)
keymap("n", "<C-l>", "<C-w>l", opts)
keymap("n", "<leader>h", "<C-w>h", opts)
keymap("n", "<leader>j", "<C-w>j", opts)
keymap("n", "<leader>k", "<C-w>k", opts)
keymap("n", "<leader>l", "<C-w>l", opts)
keymap("n", "<leader>e", ":NvimTreeToggle<cr>", opts)
@ -80,3 +80,8 @@ keymap("t", "<C-l>", "<C-\\><C-N><C-w>l", term_opts)
keymap("n", "<leader>f", "<cmd>lua require'telescope.builtin'.find_files(require('telescope.themes').get_dropdown({ previewer = false }))<cr>", opts)
keymap("n", "<c-t>", "<cmd>Telescope live_grep<cr>", opts)
-- Format document --
keymap("n", "<leader><leader>f", "<cmd>Format<cr>", opts)
-- close buffer --
keymap("n", "<leader>q", "<cmd>Bdelete! %d<cr>",opts)

View File

@ -0,0 +1,17 @@
local null_ls_status_ok, null_ls = pcall(require, "null-ls")
if not null_ls_status_ok then
return
end
-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/formatting
local formatting = null_ls.builtins.formatting
-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics
local diagnostics = null_ls.builtins.diagnostics
null_ls.setup {
debug = false,
sources = {
formatting.clang_format,
diagnostics.gccdiag,
},
}