autoformat
This commit is contained in:
@@ -2,41 +2,41 @@ require("lazy").setup({
|
|||||||
"navarasu/onedark.nvim",
|
"navarasu/onedark.nvim",
|
||||||
|
|
||||||
-- Auto-completion engine
|
-- Auto-completion engine
|
||||||
{
|
{
|
||||||
"hrsh7th/nvim-cmp",
|
"hrsh7th/nvim-cmp",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"hrsh7th/cmp-nvim-lsp", -- lsp auto-completion
|
"hrsh7th/cmp-nvim-lsp", -- lsp auto-completion
|
||||||
"hrsh7th/cmp-buffer", -- buffer auto-completion
|
"hrsh7th/cmp-buffer", -- buffer auto-completion
|
||||||
"hrsh7th/cmp-path", -- path auto-completion
|
"hrsh7th/cmp-path", -- path auto-completion
|
||||||
"hrsh7th/cmp-cmdline", -- cmdline auto-completion
|
"hrsh7th/cmp-cmdline", -- cmdline auto-completion
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
require("config.nvim-cmp")
|
require("config.nvim-cmp")
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
-- Code snippet engine
|
-- Code snippet engine
|
||||||
{
|
{
|
||||||
"L3MON4D3/LuaSnip",
|
"L3MON4D3/LuaSnip",
|
||||||
version = "v2.*",
|
version = "v2.*",
|
||||||
},
|
},
|
||||||
|
|
||||||
-- LSP manager
|
-- LSP manager
|
||||||
"williamboman/mason.nvim",
|
"williamboman/mason.nvim",
|
||||||
"williamboman/mason-lspconfig.nvim",
|
"williamboman/mason-lspconfig.nvim",
|
||||||
"neovim/nvim-lspconfig",
|
"neovim/nvim-lspconfig",
|
||||||
|
|
||||||
-- file explorer on the side
|
-- file explorer on the side
|
||||||
"nvim-tree/nvim-tree.lua",
|
"nvim-tree/nvim-tree.lua",
|
||||||
|
|
||||||
-- lazygit integration
|
-- lazygit integration
|
||||||
|
|
||||||
{
|
{
|
||||||
"kdheepak/lazygit.nvim",
|
"kdheepak/lazygit.nvim",
|
||||||
lazy = false,
|
lazy = false,
|
||||||
-- optional for floating window border decoration
|
-- optional for floating window border decoration
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"nvim-lua/plenary.nvim",
|
"nvim-lua/plenary.nvim",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -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({
|
require('mason-lspconfig').setup({
|
||||||
-- A list of servers to automatically install if they're not already installed
|
-- A list of servers to automatically install if they're not already installed
|
||||||
ensure_installed = servers,
|
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
|
-- Set different settings for different languages' LSP
|
||||||
-- LSP list: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
|
-- 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
|
-- How to use setup({}): https://github.com/neovim/nvim-lspconfig/wiki/Understanding-setup-%7B%7D
|
||||||
@@ -63,7 +71,7 @@ end
|
|||||||
-- 2. add configuration below
|
-- 2. add configuration below
|
||||||
|
|
||||||
for _, lsp in ipairs(servers) do
|
for _, lsp in ipairs(servers) do
|
||||||
lspconfig[lsp].setup {
|
lspconfig[lsp].setup {
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ cmp.setup({
|
|||||||
},
|
},
|
||||||
mapping = cmp.mapping.preset.insert({
|
mapping = cmp.mapping.preset.insert({
|
||||||
-- Use <C-b/f> to scroll the docs
|
-- 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),
|
['J'] = cmp.mapping.scroll_docs(4),
|
||||||
-- Use <C-k/j> to switch in items
|
-- Use <C-k/j> to switch in items
|
||||||
['k'] = cmp.mapping.select_prev_item(),
|
['k'] = cmp.mapping.select_prev_item(),
|
||||||
@@ -40,40 +40,40 @@ cmp.setup({
|
|||||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
cmp.select_prev_item()
|
cmp.select_prev_item()
|
||||||
elseif luasnip.jumpable( -1) then
|
elseif luasnip.jumpable(-1) then
|
||||||
luasnip.jump( -1)
|
luasnip.jump(-1)
|
||||||
else
|
else
|
||||||
fallback()
|
fallback()
|
||||||
end
|
end
|
||||||
end, { "i", "s" }),
|
end, { "i", "s" }),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
-- Let's configure the item's appearance
|
-- Let's configure the item's appearance
|
||||||
-- source: https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearance
|
-- source: https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearance
|
||||||
formatting = {
|
formatting = {
|
||||||
-- Set order from left to right
|
-- Set order from left to right
|
||||||
-- kind: single letter indicating the type of completion
|
-- kind: single letter indicating the type of completion
|
||||||
-- abbr: abbreviation of "word"; when not empty it is used in the menu instead of "word"
|
-- 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"
|
-- menu: extra text for the popup menu, displayed after "word" or "abbr"
|
||||||
fields = { 'abbr', 'menu' },
|
fields = { 'abbr', 'menu' },
|
||||||
|
|
||||||
-- customize the appearance of the completion menu
|
-- customize the appearance of the completion menu
|
||||||
format = function(entry, vim_item)
|
format = function(entry, vim_item)
|
||||||
vim_item.menu = ({
|
vim_item.menu = ({
|
||||||
nvim_lsp = '[Lsp]',
|
nvim_lsp = '[Lsp]',
|
||||||
luasnip = '[Luasnip]',
|
luasnip = '[Luasnip]',
|
||||||
buffer = '[File]',
|
buffer = '[File]',
|
||||||
path = '[Path]',
|
path = '[Path]',
|
||||||
})[entry.source.name]
|
})[entry.source.name]
|
||||||
return vim_item
|
return vim_item
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Set source precedence
|
-- Set source precedence
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({
|
||||||
{ name = 'nvim_lsp' }, -- For nvim-lsp
|
{ name = 'nvim_lsp' }, -- For nvim-lsp
|
||||||
{ name = 'luasnip' }, -- For luasnip user
|
{ name = 'luasnip' }, -- For luasnip user
|
||||||
{ name = 'buffer' }, -- For buffer word completion
|
{ name = 'buffer' }, -- For buffer word completion
|
||||||
{ name = 'path' }, -- For path completion
|
{ name = 'path' }, -- For path completion
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
require("nvim-tree").setup({
|
require("nvim-tree").setup({
|
||||||
|
|
||||||
git = {
|
git = {
|
||||||
enable = true,
|
enable = true,
|
||||||
},
|
},
|
||||||
renderer = {
|
renderer = {
|
||||||
highlight_git = true,
|
highlight_git = true,
|
||||||
icons = {
|
icons = {
|
||||||
show = {
|
show = {
|
||||||
git = true,
|
git = true,
|
||||||
},
|
},
|
||||||
glyphs = {
|
glyphs = {
|
||||||
folder = {
|
folder = {
|
||||||
default = "",
|
default = "",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
local opts = {
|
local opts = {
|
||||||
noremap = true, -- non-recursive
|
noremap = true, -- non-recursive
|
||||||
silent = true, -- do not show message
|
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)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
local onedark = require("onedark")
|
local onedark = require("onedark")
|
||||||
|
|
||||||
onedark.setup{
|
onedark.setup {
|
||||||
style = "darker"
|
style = "darker"
|
||||||
}
|
}
|
||||||
onedark.load()
|
onedark.load()
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||||
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
||||||
vim.fn.system({
|
vim.fn.system({
|
||||||
"git",
|
"git",
|
||||||
"clone",
|
"clone",
|
||||||
"--filter=blob:none",
|
"--filter=blob:none",
|
||||||
"https://github.com/folke/lazy.nvim.git",
|
"https://github.com/folke/lazy.nvim.git",
|
||||||
"--branch=stable", -- latest stable release
|
"--branch=stable", -- latest stable release
|
||||||
lazypath,
|
lazypath,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
vim.opt.rtp:prepend(lazypath)
|
vim.opt.rtp:prepend(lazypath)
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
-- define common options
|
-- define common options
|
||||||
local opts = {
|
local opts = {
|
||||||
noremap = true, -- non-recursive
|
noremap = true, -- non-recursive
|
||||||
silent = true, -- do not show message
|
silent = true, -- do not show message
|
||||||
}
|
}
|
||||||
local map = vim.keymap.set
|
local map = vim.keymap.set
|
||||||
|
|
||||||
@@ -18,10 +18,10 @@ map('n', '<leader>wk', '<C-w>k', opts)
|
|||||||
map('n', '<leader>wl', '<C-w>l', opts)
|
map('n', '<leader>wl', '<C-w>l', opts)
|
||||||
|
|
||||||
local step_size = 4
|
local step_size = 4
|
||||||
map('n', '<leader>wJ', ':resize -'.. step_size ..'<CR>', opts)
|
map('n', '<leader>wJ', ':resize -' .. step_size .. '<CR>', opts)
|
||||||
map('n', '<leader>wK', ':resize +'.. step_size ..'<CR>', opts)
|
map('n', '<leader>wK', ':resize +' .. step_size .. '<CR>', opts)
|
||||||
map('n', '<leader>wH', ':vertical resize -'.. step_size ..'<CR>', opts)
|
map('n', '<leader>wH', ':vertical resize -' .. step_size .. '<CR>', opts)
|
||||||
map('n', '<leader>wL', ':vertical resize +'.. step_size ..'<CR>', opts)
|
map('n', '<leader>wL', ':vertical resize +' .. step_size .. '<CR>', opts)
|
||||||
|
|
||||||
map('n', '<leader>wn', ':windo new<CR>', opts)
|
map('n', '<leader>wn', ':windo new<CR>', opts)
|
||||||
map('n', '<leader>wc', ':close<CR>', opts)
|
map('n', '<leader>wc', ':close<CR>', opts)
|
||||||
|
|||||||
@@ -1,26 +1,26 @@
|
|||||||
-- Hint: use `:h <option>` to figure out the meaning if needed
|
-- Hint: use `:h <option>` to figure out the meaning if needed
|
||||||
vim.opt.clipboard = 'unnamedplus' -- use system clipboard
|
vim.opt.clipboard = 'unnamedplus' -- use system clipboard
|
||||||
vim.opt.completeopt = {'menu', 'menuone', 'noselect'}
|
vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
|
||||||
vim.opt.mouse = 'a' -- allow the mouse to be used in Nvim
|
vim.opt.mouse = 'a' -- allow the mouse to be used in Nvim
|
||||||
|
|
||||||
-- Tab
|
-- Tab
|
||||||
local tabstops = 4
|
local tabstops = 4
|
||||||
vim.opt.tabstop = tabstops -- number of visual spaces per TAB
|
vim.opt.tabstop = tabstops -- number of visual spaces per TAB
|
||||||
vim.opt.softtabstop = tabstops -- number of spacesin tab when editing
|
vim.opt.softtabstop = tabstops -- number of spacesin tab when editing
|
||||||
vim.opt.shiftwidth = tabstops -- insert 4 spaces on a tab
|
vim.opt.shiftwidth = tabstops -- insert 4 spaces on a tab
|
||||||
vim.opt.expandtab = true -- tabs are spaces, mainly because of python
|
vim.opt.expandtab = true -- tabs are spaces, mainly because of python
|
||||||
|
|
||||||
-- UI config
|
-- UI config
|
||||||
vim.opt.number = true -- add numbers to each line on the left side
|
vim.opt.number = true -- add numbers to each line on the left side
|
||||||
vim.opt.relativenumber = true -- show relative numbers
|
vim.opt.relativenumber = true -- show relative numbers
|
||||||
vim.opt.cursorline = true -- highlight cursor line underneath the cursor horizontally
|
vim.opt.cursorline = true -- highlight cursor line underneath the cursor horizontally
|
||||||
vim.opt.splitbelow = true -- open new vertical split bottom
|
vim.opt.splitbelow = true -- open new vertical split bottom
|
||||||
vim.opt.splitright = true -- open new horizontal splits right
|
vim.opt.splitright = true -- open new horizontal splits right
|
||||||
vim.opt.termguicolors = true -- enabl 24-bit RGB color in the TUI
|
vim.opt.termguicolors = true -- enabl 24-bit RGB color in the TUI
|
||||||
vim.opt.showmode = true -- we are experienced,we know we need the "-- INSERT --" mode hint
|
vim.opt.showmode = true -- we are experienced,we know we need the "-- INSERT --" mode hint
|
||||||
|
|
||||||
-- Searching
|
-- Searching
|
||||||
vim.opt.incsearch = true -- search as characters are entered
|
vim.opt.incsearch = true -- search as characters are entered
|
||||||
vim.opt.hlsearch = true -- highlight matches
|
vim.opt.hlsearch = true -- highlight matches
|
||||||
vim.opt.ignorecase = true -- ignore case in searches by default
|
vim.opt.ignorecase = true -- ignore case in searches by default
|
||||||
vim.opt.smartcase = true -- but make it case sensitive if an uppercase is entered
|
vim.opt.smartcase = true -- but make it case sensitive if an uppercase is entered
|
||||||
|
|||||||
Reference in New Issue
Block a user