autoformat

This commit is contained in:
2024-09-30 06:12:57 +02:00
parent 2bed3cbe6e
commit b9b77abfa4
8 changed files with 116 additions and 109 deletions

View File

@@ -2,41 +2,41 @@ require("lazy").setup({
"navarasu/onedark.nvim",
-- Auto-completion engine
{
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-nvim-lsp", -- lsp auto-completion
"hrsh7th/cmp-buffer", -- buffer auto-completion
"hrsh7th/cmp-path", -- path auto-completion
"hrsh7th/cmp-cmdline", -- cmdline auto-completion
},
config = function()
require("config.nvim-cmp")
end,
},
-- Code snippet engine
{
"L3MON4D3/LuaSnip",
version = "v2.*",
},
{
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-nvim-lsp", -- lsp auto-completion
"hrsh7th/cmp-buffer", -- buffer auto-completion
"hrsh7th/cmp-path", -- path auto-completion
"hrsh7th/cmp-cmdline", -- cmdline auto-completion
},
config = function()
require("config.nvim-cmp")
end,
},
-- Code snippet engine
{
"L3MON4D3/LuaSnip",
version = "v2.*",
},
-- LSP manager
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
"neovim/nvim-lspconfig",
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
"neovim/nvim-lspconfig",
-- file explorer on the side
"nvim-tree/nvim-tree.lua",
-- lazygit integration
{
"kdheepak/lazygit.nvim",
lazy = false,
-- optional for floating window border decoration
dependencies = {
"nvim-lua/plenary.nvim",
{
"kdheepak/lazygit.nvim",
lazy = false,
-- optional for floating window border decoration
dependencies = {
"nvim-lua/plenary.nvim",
},
},
},
})

View File

@@ -8,13 +8,21 @@ require('mason').setup({
}
})
local servers = { 'pylsp', 'lua_ls', 'rust_analyzer', 'zls'}
local servers = { 'pylsp', 'lua_ls', 'rust_analyzer', 'zls' }
require('mason-lspconfig').setup({
-- A list of servers to automatically install if they're not already installed
ensure_installed = servers,
})
-- auto format on save
vim.api.nvim_create_autocmd("BufWritePre", {
buffer = vim.b.buffer,
callback = function()
vim.lsp.buf.format { async = false }
end
})
-- Set different settings for different languages' LSP
-- LSP list: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
-- How to use setup({}): https://github.com/neovim/nvim-lspconfig/wiki/Understanding-setup-%7B%7D
@@ -63,7 +71,7 @@ end
-- 2. add configuration below
for _, lsp in ipairs(servers) do
lspconfig[lsp].setup {
on_attach = on_attach,
}
lspconfig[lsp].setup {
on_attach = on_attach,
}
end

View File

@@ -16,7 +16,7 @@ cmp.setup({
},
mapping = cmp.mapping.preset.insert({
-- Use <C-b/f> to scroll the docs
['K'] = cmp.mapping.scroll_docs( -4),
['K'] = cmp.mapping.scroll_docs(-4),
['J'] = cmp.mapping.scroll_docs(4),
-- Use <C-k/j> to switch in items
['k'] = cmp.mapping.select_prev_item(),
@@ -40,40 +40,40 @@ cmp.setup({
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable( -1) then
luasnip.jump( -1)
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
}),
-- Let's configure the item's appearance
-- source: https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearance
formatting = {
-- Set order from left to right
-- kind: single letter indicating the type of completion
-- abbr: abbreviation of "word"; when not empty it is used in the menu instead of "word"
-- menu: extra text for the popup menu, displayed after "word" or "abbr"
fields = { 'abbr', 'menu' },
-- Let's configure the item's appearance
-- source: https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearance
formatting = {
-- Set order from left to right
-- kind: single letter indicating the type of completion
-- abbr: abbreviation of "word"; when not empty it is used in the menu instead of "word"
-- menu: extra text for the popup menu, displayed after "word" or "abbr"
fields = { 'abbr', 'menu' },
-- customize the appearance of the completion menu
format = function(entry, vim_item)
vim_item.menu = ({
nvim_lsp = '[Lsp]',
luasnip = '[Luasnip]',
buffer = '[File]',
path = '[Path]',
})[entry.source.name]
return vim_item
end,
},
-- customize the appearance of the completion menu
format = function(entry, vim_item)
vim_item.menu = ({
nvim_lsp = '[Lsp]',
luasnip = '[Luasnip]',
buffer = '[File]',
path = '[Path]',
})[entry.source.name]
return vim_item
end,
},
-- Set source precedence
sources = cmp.config.sources({
{ name = 'nvim_lsp' }, -- For nvim-lsp
{ name = 'luasnip' }, -- For luasnip user
{ name = 'buffer' }, -- For buffer word completion
{ name = 'path' }, -- For path completion
})
-- Set source precedence
sources = cmp.config.sources({
{ name = 'nvim_lsp' }, -- For nvim-lsp
{ name = 'luasnip' }, -- For luasnip user
{ name = 'buffer' }, -- For buffer word completion
{ name = 'path' }, -- For path completion
})
})

View File

@@ -1,25 +1,25 @@
require("nvim-tree").setup({
git = {
git = {
enable = true,
},
renderer = {
},
renderer = {
highlight_git = true,
icons = {
show = {
git = true,
},
glyphs = {
folder = {
default = "",
show = {
git = true,
},
glyphs = {
folder = {
default = "",
},
},
},
},
},
})
},
})
local opts = {
noremap = true, -- non-recursive
silent = true, -- do not show message
noremap = true, -- non-recursive
silent = true, -- do not show message
}
vim.keymap.set('n', "<leader>e", function () require("nvim-tree.api").tree.toggle() end, opts)
vim.keymap.set('n', "<leader>e", function() require("nvim-tree.api").tree.toggle() end, opts)

View File

@@ -1,6 +1,6 @@
local onedark = require("onedark")
onedark.setup{
onedark.setup {
style = "darker"
}
onedark.load()

View File

@@ -1,13 +1,12 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)