nvim config autoformat

This commit is contained in:
Henrik Bakken
2021-12-13 12:20:52 +01:00
parent c8351d13ca
commit c9b2f04369
+46 -77
View File
@@ -169,8 +169,7 @@ local install_path = vim.fn.stdpath("data") ..
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
vim.fn.system({ vim.fn.system({
"git", "clone", "https://github.com/wbthomason/packer.nvim", "git", "clone", "https://github.com/wbthomason/packer.nvim", install_path
install_path
}) })
vim.api.nvim_command "packadd packer.nvim" vim.api.nvim_command "packadd packer.nvim"
end end
@@ -247,10 +246,7 @@ require("packer").startup {
"kyazdani42/nvim-tree.lua", "kyazdani42/nvim-tree.lua",
requires = {"kyazdani42/nvim-web-devicons"}, requires = {"kyazdani42/nvim-web-devicons"},
config = function() config = function()
require("nvim-tree").setup { require("nvim-tree").setup {disable_netrw = false, auto_close = true}
disable_netrw = false,
auto_close = true
}
local map = vim.api.nvim_set_keymap local map = vim.api.nvim_set_keymap
map("n", "<C-p>", ":NvimTreeToggle<cr>", {noremap = true}) map("n", "<C-p>", ":NvimTreeToggle<cr>", {noremap = true})
end end
@@ -271,10 +267,7 @@ require("packer").startup {
use {"NLKNguyen/papercolor-theme"} use {"NLKNguyen/papercolor-theme"}
use {"drewtempelmeyer/palenight.vim"} use {"drewtempelmeyer/palenight.vim"}
use {"altercation/vim-colors-solarized"} use {"altercation/vim-colors-solarized"}
use { use {"rakr/vim-one", config = function() vim.g.one_allow_italics = 1 end}
"rakr/vim-one",
config = function() vim.g.one_allow_italics = 1 end
}
use { use {
"ayu-theme/ayu-vim", "ayu-theme/ayu-vim",
@@ -314,8 +307,7 @@ require("packer").startup {
use { use {
"danilamihailov/beacon.nvim", "danilamihailov/beacon.nvim",
setup = function() setup = function()
vim.api.nvim_exec([[highlight Beacon guibg=white ctermbg=15]], vim.api.nvim_exec([[highlight Beacon guibg=white ctermbg=15]], false)
false)
end, end,
config = function() config = function()
vim.g.beacon_size = 40 vim.g.beacon_size = 40
@@ -410,9 +402,7 @@ require("packer").startup {
"akinsho/nvim-bufferline.lua", "akinsho/nvim-bufferline.lua",
requires = {"kyazdani42/nvim-web-devicons"}, requires = {"kyazdani42/nvim-web-devicons"},
config = function() config = function()
require("bufferline").setup { require("bufferline").setup {options = {diagnostics = "nvim_lsp"}}
options = {diagnostics = "nvim_lsp"}
}
local map = vim.api.nvim_set_keymap local map = vim.api.nvim_set_keymap
map("n", "<M-J>", ":BufferLineCyclePrev<cr>", map("n", "<M-J>", ":BufferLineCyclePrev<cr>",
{noremap = true, silent = true}) {noremap = true, silent = true})
@@ -431,10 +421,9 @@ require("packer").startup {
require("FTerm").setup {} require("FTerm").setup {}
local map = vim.api.nvim_set_keymap local map = vim.api.nvim_set_keymap
local opts = {noremap = true, silent = true} local opts = {noremap = true, silent = true}
map("n", "<F2>", [[<cmd>lua require("FTerm").toggle()<cr>]], map("n", "<F2>", [[<cmd>lua require("FTerm").toggle()<cr>]], opts)
map("t", "<F2>", [[<C-\><C-n><cmd>lua require("FTerm").toggle()<cr>]],
opts) opts)
map("t", "<F2>",
[[<C-\><C-n><cmd>lua require("FTerm").toggle()<cr>]], opts)
end end
} }
@@ -445,9 +434,7 @@ require("packer").startup {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
run = ":TSUpdate", run = ":TSUpdate",
config = function() config = function()
require("nvim-treesitter.configs").setup { require("nvim-treesitter.configs").setup {ensure_installed = "all"}
ensure_installed = "all"
}
vim.opt.foldexpr = "nvim_treesitter#foldexpr()" vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
end end
} }
@@ -471,14 +458,12 @@ require("packer").startup {
map("n", "<M-b>", "<cmd>Telescope buffers<cr>", opts) map("n", "<M-b>", "<cmd>Telescope buffers<cr>", opts)
map("n", "<M-y>", "<cmd>Telescope filetypes<cr>", opts) map("n", "<M-y>", "<cmd>Telescope filetypes<cr>", opts)
map("n", "<F3>", "<cmd>Telescope colorscheme<cr>", opts) map("n", "<F3>", "<cmd>Telescope colorscheme<cr>", opts)
map("n", "<leader>la", "<cmd>Telescope lsp_code_actions<cr>", map("n", "<leader>la", "<cmd>Telescope lsp_code_actions<cr>", opts)
map("v", "<leader>la", "<cmd>Telescope lsp_range_code_actions<cr>", opts)
map("n", "<leader>ld", "<cmd>Telescope lsp_document_diagnostics<cr>",
opts)
map("n", "<leader>lD", "<cmd>Telescope lsp_workspace_diagnostics<cr>",
opts) opts)
map("v", "<leader>la",
"<cmd>Telescope lsp_range_code_actions<cr>", opts)
map("n", "<leader>ld",
"<cmd>Telescope lsp_document_diagnostics<cr>", opts)
map("n", "<leader>lD",
"<cmd>Telescope lsp_workspace_diagnostics<cr>", opts)
map("n", "<F12>", "<cmd>Telescope<cr>", opts) map("n", "<F12>", "<cmd>Telescope<cr>", opts)
require("telescope").setup { require("telescope").setup {
defaults = { defaults = {
@@ -489,8 +474,7 @@ require("packer").startup {
["<C-k>"] = actions.move_selection_previous, ["<C-k>"] = actions.move_selection_previous,
["<C-b>"] = actions.preview_scrolling_up, ["<C-b>"] = actions.preview_scrolling_up,
["<C-f>"] = actions.preview_scrolling_down, ["<C-f>"] = actions.preview_scrolling_down,
["<cr>"] = actions.select_default + ["<cr>"] = actions.select_default + actions.center,
actions.center,
["<C-s>"] = actions.select_horizontal, ["<C-s>"] = actions.select_horizontal,
["<C-v>"] = actions.select_vertical, ["<C-v>"] = actions.select_vertical,
["<C-t>"] = actions.select_tab, ["<C-t>"] = actions.select_tab,
@@ -498,8 +482,7 @@ require("packer").startup {
actions.move_selection_worse, actions.move_selection_worse,
["<Tab>"] = actions.toggle_selection + ["<Tab>"] = actions.toggle_selection +
actions.move_selection_better, actions.move_selection_better,
["<C-q>"] = actions.send_to_qflist + ["<C-q>"] = actions.send_to_qflist + actions.open_qflist,
actions.open_qflist,
["<M-q>"] = actions.send_selected_to_qflist + ["<M-q>"] = actions.send_selected_to_qflist +
actions.open_qflist, actions.open_qflist,
["<C-l>"] = actions.complete_tag ["<C-l>"] = actions.complete_tag
@@ -516,27 +499,25 @@ require("packer").startup {
"romgrk/nvim-treesitter-context", "romgrk/nvim-treesitter-context",
requires = {"nvim-treesitter/nvim-treesitter"}, requires = {"nvim-treesitter/nvim-treesitter"},
config = function() config = function()
require("treesitter-context").setup{ require("treesitter-context").setup {
enable = true, -- Enable this plugin (Can be enabled/disabled later via commands) enable = true, -- Enable this plugin (Can be enabled/disabled later via commands)
throttle = true, -- Throttles plugin updates (may improve performance) throttle = true, -- Throttles plugin updates (may improve performance)
max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit. max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit.
patterns = { patterns = {
default = { default = {
"class", "class", "function", "method"
"function",
"method",
-- 'for', -- These won't appear in the context -- 'for', -- These won't appear in the context
-- 'while', -- 'while',
-- 'if', -- 'if',
-- 'switch', -- 'switch',
-- 'case', -- 'case',
}, }
-- Example for a specific filetype. -- Example for a specific filetype.
-- If a pattern is missing, *open a PR* so everyone can benefit. -- If a pattern is missing, *open a PR* so everyone can benefit.
-- rust = { -- rust = {
-- 'impl_item', -- 'impl_item',
-- }, -- },
}, }
} }
end end
} }
@@ -563,7 +544,8 @@ require("packer").startup {
}), }),
['<TAB>'] = cmp.mapping({ ['<TAB>'] = cmp.mapping({
c = function(fallback) c = function(fallback)
if #cmp.core:get_sources() > 0 and not cmp.get_config().experimental.native_menu then if #cmp.core:get_sources() > 0 and
not cmp.get_config().experimental.native_menu then
if cmp.visible() then if cmp.visible() then
cmp.select_next_item() cmp.select_next_item()
else else
@@ -572,11 +554,12 @@ require("packer").startup {
else else
fallback() fallback()
end end
end, end
}), }),
['<S-TAB>'] = cmp.mapping({ ['<S-TAB>'] = cmp.mapping({
c = function(fallback) c = function(fallback)
if #cmp.core:get_sources() > 0 and not cmp.get_config().experimental.native_menu then if #cmp.core:get_sources() > 0 and
not cmp.get_config().experimental.native_menu then
if cmp.visible() then if cmp.visible() then
cmp.select_prev_item() cmp.select_prev_item()
else else
@@ -585,15 +568,13 @@ require("packer").startup {
else else
fallback() fallback()
end end
end, end
}), })
}, },
sources = { sources = {
{name = "nvim_lsp"}, {name = "nvim_lsp"}, {name = "buffer"}, {name = "path"},
{name = "buffer"}, {name = "nvim_lua"}
{name = "path"}, }
{name = "nvim_lua"},
},
}) })
end end
} }
@@ -695,8 +676,7 @@ require("packer").startup {
bmap(bufnr, "n", "<leader>wa", bmap(bufnr, "n", "<leader>wa",
"<cmd>lua vim.lsp.buf.add_workspace_folder()<cr>", opts) "<cmd>lua vim.lsp.buf.add_workspace_folder()<cr>", opts)
bmap(bufnr, "n", "<leader>wr", bmap(bufnr, "n", "<leader>wr",
"<cmd>lua vim.lsp.buf.remove_workspace_folder()<cr>", "<cmd>lua vim.lsp.buf.remove_workspace_folder()<cr>", opts)
opts)
bmap(bufnr, "n", "<leader>wl", bmap(bufnr, "n", "<leader>wl",
"<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<cr>", "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<cr>",
opts) opts)
@@ -714,26 +694,22 @@ require("packer").startup {
"<cmd>lua vim.lsp.diagnostic.goto_prev({severity_limit='Warning', popup_opts={show_header=false}})<cr>", "<cmd>lua vim.lsp.diagnostic.goto_prev({severity_limit='Warning', popup_opts={show_header=false}})<cr>",
opts) opts)
-- popups -- popups
bmap(bufnr, "n", "<M-x>", bmap(bufnr, "n", "<M-x>", "<cmd>lua vim.lsp.buf.signature_help()<cr>",
"<cmd>lua vim.lsp.buf.signature_help()<cr>", opts) opts)
bmap(bufnr, "i", "<M-x>", bmap(bufnr, "i", "<M-x>", "<cmd>lua vim.lsp.buf.signature_help()<cr>",
"<cmd>lua vim.lsp.buf.signature_help()<cr>", opts) opts)
-- other -- other
if client.resolved_capabilities.goto_definition then if client.resolved_capabilities.goto_definition then
bmap(bufnr, "n", "gd", bmap(bufnr, "n", "gd", ":lua vim.lsp.buf.definition()<cr>", opts)
":lua vim.lsp.buf.definition()<cr>", opts)
end end
if client.resolved_capabilities.find_references then if client.resolved_capabilities.find_references then
bmap(bufnr, "n", "gr", bmap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<cr>", opts)
"<cmd>lua vim.lsp.buf.references()<cr>", opts)
end end
if client.resolved_capabilities.hover then if client.resolved_capabilities.hover then
bmap(bufnr, "n", "K", bmap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<cr>", opts)
"<cmd>lua vim.lsp.buf.hover()<cr>", opts)
end end
if client.resolved_capabilities.rename then if client.resolved_capabilities.rename then
bmap(bufnr, "n", "<M-r>", bmap(bufnr, "n", "<M-r>", "<cmd>lua vim.lsp.buf.rename()<cr>", opts)
"<cmd>lua vim.lsp.buf.rename()<cr>", opts)
end end
if client.resolved_capabilities.document_formatting or if client.resolved_capabilities.document_formatting or
client.resolved_capabilities.document_range_formatting then client.resolved_capabilities.document_range_formatting then
@@ -758,17 +734,13 @@ require("packer").startup {
settings = { settings = {
yaml = { yaml = {
customTags = { customTags = {
"!ChildAccessor mapping", "!ChildAccessor mapping", "!ChildContainer mapping",
"!ChildContainer mapping",
"!ConstantAccessor mapping", "!Dtype scalar", "!ConstantAccessor mapping", "!Dtype scalar",
"!ConstantTensorAccessor mapping", "!ConstantTensorAccessor mapping", "!DtypeTensor scalar",
"!DtypeTensor scalar", "!ImportClass scalar", "!ImportClass scalar", "!ReferenceContainer mapping",
"!ReferenceContainer mapping", "!ReferenceLink mapping", "!SeriesTensor mapping",
"!ReferenceLink mapping", "!SeriesTensorAccessor mapping", "!UDFtensorfactory scalar",
"!SeriesTensor mapping", "!UDFnu scalar", "!UDFvalidator scalar", "!Unit scalar",
"!SeriesTensorAccessor mapping",
"!UDFtensorfactory scalar", "!UDFnu scalar",
"!UDFvalidator scalar", "!Unit scalar",
"!UserClass mapping", "!UserInstance mapping", "!UserClass mapping", "!UserInstance mapping",
"!getattr mapping" "!getattr mapping"
} }
@@ -783,7 +755,7 @@ require("packer").startup {
diagnosticMode = "workspace", diagnosticMode = "workspace",
logLevel = "Warning", logLevel = "Warning",
typeCheckingMode = "basic", typeCheckingMode = "basic",
autoImportCompletions = false, autoImportCompletions = false
} }
} }
} }
@@ -791,9 +763,7 @@ require("packer").startup {
nvim_lsp.efm.setup { nvim_lsp.efm.setup {
on_attach = on_attach, on_attach = on_attach,
init_options = {documentFormatting = true}, init_options = {documentFormatting = true},
filetypes = { filetypes = {"python", "markdown", "yaml", "lua", "javascript"},
"python", "markdown", "yaml", "lua", "javascript"
},
root_dir = vim.loop.cwd, root_dir = vim.loop.cwd,
settings = { settings = {
rootMarkers = {".git/"}, rootMarkers = {".git/"},
@@ -828,7 +798,6 @@ require("packer").startup {
} }
} }
} }
} }
end end
} }