nvim: File formatting
This commit is contained in:
parent
2b9981482f
commit
8f6e1994df
2 changed files with 20 additions and 19 deletions
|
@ -38,10 +38,12 @@ local function wrap_up()
|
|||
if vim.v.count == 0 then return 'gk' end
|
||||
return 'k'
|
||||
end
|
||||
|
||||
local function wrap_down()
|
||||
if vim.v.count == 0 then return 'gj' end
|
||||
return 'j'
|
||||
end
|
||||
|
||||
map.n.nore.expr['k'] = wrap_up
|
||||
map.n.nore.expr['j'] = wrap_down
|
||||
|
||||
|
@ -54,7 +56,7 @@ map.i.nore['<C-l>'] = '<esc>guiw`]a'
|
|||
|
||||
-- let me save stuff as sudo when I forget to call vim with it
|
||||
map.c.nore['w!!'] =
|
||||
[[execute 'silent! write !sudo tee % >/dev/null' <bar> edit!]]
|
||||
[[execute 'silent! write !sudo tee % >/dev/null' <bar> edit!]]
|
||||
|
||||
-- yank current filename/filepath to f buffer
|
||||
map.n.nore['yp'] = ':let @p = expand("%")<Cr>'
|
||||
|
@ -123,16 +125,16 @@ map.n.nore['<leader>E'] = ':Vifm getcwd()<cr>'
|
|||
-- PLUGIN: Telescope GLOBAL FUZZY FINDING
|
||||
-- buffers and files in current workdir
|
||||
map.n.nore['<leader>s'] =
|
||||
[[:lua require 'telescope.builtin'.buffers(require 'telescope.themes'.get_ivy())<cr>]]
|
||||
[[:lua require 'telescope.builtin'.buffers(require 'telescope.themes'.get_ivy())<cr>]]
|
||||
-- most recently used / MRU, bound to S since it is essentially a larger
|
||||
-- go-back intention than just buffers
|
||||
map.n.nore['<leader>S'] =
|
||||
[[:lua require 'telescope.builtin'.oldfiles(require 'telescope.themes'.get_ivy())<cr>]]
|
||||
[[:lua require 'telescope.builtin'.oldfiles(require 'telescope.themes'.get_ivy())<cr>]]
|
||||
-- fuzzy find files in cwd
|
||||
map.n.nore['<leader>f'] = [[:lua require 'telescope.builtin'.find_files()<cr>]]
|
||||
-- fuzzy find hidden files in cwd
|
||||
map.n.nore['<leader><c-f>'] =
|
||||
[[:lua require 'telescope.builtin'.find_files({hidden=true})<cr>]]
|
||||
[[:lua require 'telescope.builtin'.find_files({hidden=true})<cr>]]
|
||||
-- general full-text search in cwd with rg
|
||||
map.n.nore['<leader>F'] = [[:lua require 'telescope.builtin'.live_grep()<cr>]]
|
||||
|
||||
|
@ -140,25 +142,25 @@ map.n.nore['<leader>F'] = [[:lua require 'telescope.builtin'.live_grep()<cr>]]
|
|||
map.n.nore['<leader>gs'] = [[:lua require 'telescope.builtin'.git_status()<cr>]]
|
||||
-- git buffercommits
|
||||
map.n.nore['<leader>gb'] =
|
||||
[[:lua require 'telescope.builtin'.git_bcommits()<cr>]]
|
||||
[[:lua require 'telescope.builtin'.git_bcommits()<cr>]]
|
||||
-- git commitlog
|
||||
map.n.nore['<leader>gl'] =
|
||||
[[:lua require 'telescope.builtin'.git_commits()<cr>]]
|
||||
[[:lua require 'telescope.builtin'.git_commits()<cr>]]
|
||||
|
||||
-- helptags
|
||||
map.n.nore['<leader><F1>'] =
|
||||
[[:lua require 'telescope.builtin'.help_tags()<cr>]]
|
||||
[[:lua require 'telescope.builtin'.help_tags()<cr>]]
|
||||
-- manpages
|
||||
map.n.nore['<leader><F2>'] =
|
||||
[[:lua require 'telescope.builtin'.man_pages()<cr>]]
|
||||
[[:lua require 'telescope.builtin'.man_pages()<cr>]]
|
||||
|
||||
-- colorschemes
|
||||
map.n.nore['<leader><F8>'] =
|
||||
[[:lua require 'telescope.builtin'.colorscheme(require 'telescope.themes'.get_ivy())<cr>]]
|
||||
[[:lua require 'telescope.builtin'.colorscheme(require 'telescope.themes'.get_ivy())<cr>]]
|
||||
|
||||
-- spell suggestions
|
||||
map.n.nore['z='] =
|
||||
[[:lua require 'telescope.builtin'.spell_suggest(require 'telescope.themes'.get_ivy())<cr>]]
|
||||
[[:lua require 'telescope.builtin'.spell_suggest(require 'telescope.themes'.get_ivy())<cr>]]
|
||||
|
||||
-- PLUGIN: betterdigraphs
|
||||
-- allow normal digraph insertion on c-k, telescope search on c-k c-k
|
||||
|
@ -225,9 +227,9 @@ map.n.nore.silent['<c-p>'] = "<CMD>lua require('Navigator').previous()<CR>"
|
|||
-- lsp keymaps are set in lsp settings, only for lsp buffers
|
||||
map.i.nore.expr.silent['<c-space>'] = 'compe#complete()'
|
||||
map.i.expr['<Tab>'] =
|
||||
[[vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>']]
|
||||
[[vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>']]
|
||||
map.i.expr['<S-Tab>'] =
|
||||
[[vsnip#jumpable(-1) ? '<Plug>(vsnip-jump-next)' : '<S-Tab>']]
|
||||
[[vsnip#jumpable(-1) ? '<Plug>(vsnip-jump-next)' : '<S-Tab>']]
|
||||
|
||||
-- PLUGIN: symbols-outline.nvim
|
||||
map.n.nore.silent['<leader>o'] = "<cmd>SymbolsOutline<cr>"
|
||||
|
|
|
@ -14,7 +14,7 @@ local prettierfmt = {
|
|||
end
|
||||
}
|
||||
local shfmt = {
|
||||
function() return {exe = "shfmt", args = {"-i 4"}, stdin = true} end
|
||||
function() return { exe = "shfmt", args = { "-i 4" }, stdin = true } end
|
||||
}
|
||||
|
||||
local formatters = {
|
||||
|
@ -29,20 +29,19 @@ local formatters = {
|
|||
}
|
||||
end
|
||||
},
|
||||
go = {function() return {exe = "goimports", stdin = true} end},
|
||||
go = { function() return { exe = "goimports", stdin = true } end },
|
||||
html = prettierfmt,
|
||||
javascript = prettierfmt,
|
||||
json = prettierfmt,
|
||||
lua = {
|
||||
function()
|
||||
return
|
||||
{exe = "lua-format", args = {"--indent-width", 4}, stdin = true}
|
||||
return { exe = "lua-format", args = { "--indent-width", 4 }, stdin = true }
|
||||
end
|
||||
},
|
||||
python = {function() return {exe = "black", args = {"-"}, stdin = true} end},
|
||||
python = { function() return { exe = "black", args = { "-" }, stdin = true } end },
|
||||
rust = {
|
||||
function()
|
||||
return {exe = "rustfmt", args = {"--emit=stdout"}, stdin = true}
|
||||
return { exe = "rustfmt", args = { "--emit=stdout" }, stdin = true }
|
||||
end
|
||||
},
|
||||
sh = shfmt,
|
||||
|
@ -50,7 +49,7 @@ local formatters = {
|
|||
zsh = shfmt
|
||||
}
|
||||
|
||||
require('formatter').setup({logging = false, filetype = formatters})
|
||||
require('formatter').setup({ logging = false, filetype = formatters })
|
||||
|
||||
-- Format on save:
|
||||
-- gather filetypes to autocorrect for each activated formatter above
|
||||
|
|
Loading…
Reference in a new issue