Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

first commit #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions README.md

This file was deleted.

20 changes: 20 additions & 0 deletions init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require("settings")
require("packer-plugins")
require("maps")

require("configs.lualine") -- 启动状态栏
require("configs.bufferline") -- 启动标签栏/标签页
require("configs.neo-tree") -- 目录树
require("configs.toggleterm") -- Terminal
require("configs.autopairs") -- autopairs
require("configs.lsp") -- lsp
require("configs.mason") -- mason
require("configs.mason-lsp") -- mason-lspconfig

require("configs.notify") -- notify

require("configs.fidget") -- fidget
require("configs.cmp") -- cmp
require("configs.lsp_signature") -- lsp_signature
require("configs.treesitter") -- treesitter
--require("configs.null-ls") -- null-ls
5 changes: 5 additions & 0 deletions lua/configs/autopairs.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
local status, autopairs = pcall(require, "nvim-autopairs")

if status then
autopairs.setup()
end
121 changes: 121 additions & 0 deletions lua/configs/bufferline.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
local status, bufferline= pcall(require, 'bufferline')

if not status then
return
end
bufferline.setup {
options = {
mode = "buffers", -- set to "tabs" to only show tabpages instead
--style_preset = bufferline.style_preset.default, -- or bufferline.style_preset.minimal,
--themable = true | false, -- allows highlight groups to be overriden i.e. sets highlights as default
--numbers = "none" | "ordinal" | "buffer_id" | "both" | function({ ordinal, id, lower, raise }): string,
numbers = "buffer_id", -- 打开文件的buffer编号
close_command = "bdelete! %d", -- can be a string | function, | false see "Mouse actions"
right_mouse_command = "bdelete! %d", -- can be a string | function | false, see "Mouse actions"
left_mouse_command = "buffer %d", -- can be a string | function, | false see "Mouse actions"
middle_mouse_command = nil, -- can be a string | function, | false see "Mouse actions"
indicator = {
icon = '▎', -- this should be omitted if indicator style is not 'icon'
--style = 'icon' | 'underline' | 'none',
},
buffer_close_icon = '󰅖',
modified_icon = '●',
close_icon = '',
left_trunc_marker = '',
right_trunc_marker = '',
--- name_formatter can be used to change the buffer's label in the bufferline.
--- Please note some names can/will break the
--- bufferline so use this at your discretion knowing that it has
--- some limitations that will *NOT* be fixed.
name_formatter = function(buf) -- buf contains:
-- name | str | the basename of the active file
-- path | str | the full path of the active file
-- bufnr (buffer only) | int | the number of the active buffer
-- buffers (tabs only) | table(int) | the numbers of the buffers in the tab
-- tabnr (tabs only) | int | the "handle" of the tab, can be converted to its ordinal number using: `vim.api.nvim_tabpage_get_number(buf.tabnr)`
end,
max_name_length = 18,
max_prefix_length = 15, -- prefix used when a buffer is de-duplicated
truncate_names = true, -- whether or not tab names should be truncated
tab_size = 18,
--diagnostics = false | "nvim_lsp" | "coc",
diagnostics = "nvim_lsp",
diagnostics_update_in_insert = false,
-- The diagnostics indicator can be set to nil to keep the buffer name highlight but delete the highlighting
diagnostics_indicator = function(count, level, diagnostics_dict, context)
return "("..count..")"
end,
-- NOTE: this will be called a lot so don't do any heavy processing here
custom_filter = function(buf_number, buf_numbers)
-- filter out filetypes you don't want to see
if vim.bo[buf_number].filetype ~= "<i-dont-want-to-see-this>" then
return true
end
-- filter out by buffer name
if vim.fn.bufname(buf_number) ~= "<buffer-name-I-dont-want>" then
return true
end
-- filter out based on arbitrary rules
-- e.g. filter out vim wiki buffer from tabline in your work repo
if vim.fn.getcwd() == "<work-repo>" and vim.bo[buf_number].filetype ~= "wiki" then
return true
end
-- filter out by it's index number in list (don't show first buffer)
if buf_numbers[1] ~= buf_number then
return true
end
end,
offsets = {
{
--filetype = "NvimTree",
filetype = "neo-tree", -- 让出文件树的位置
--text = "File Explorer" | function ,
text = "File Explorer",
--text_align = "left" | "center" | "right" -- 文件名对齐方式
text_align = "left",
--separator = true
}
},
--color_icons = true | false, -- whether or not to add the filetype icon highlights
color_icons = true, --彩色图标
get_element_icon = function(element)
-- element consists of {filetype: string, path: string, extension: string, directory: string}
-- This can be used to change how bufferline fetches the icon
-- for an element e.g. a buffer or a tab.
-- e.g.
local icon, hl = require('nvim-web-devicons').get_icon_by_filetype(element.filetype, { default = false })
return icon, hl
-- or
----local custom_map = {my_thing_ft: {icon = "my_thing_icon", hl}}
----return custom_map[element.filetype]
end,
--show_buffer_icons = true | false, -- disable filetype icons for buffers
show_buffer_icons = true,
--show_buffer_close_icons = true | false,
show_buffer_close_icons = true,
--show_close_icon = true | false,
show_close_icon = true,
--show_tab_indicators = true | false,
show_tab_indicators = true,
--show_duplicate_prefix = true | false, -- whether to show duplicate buffer prefix
persist_buffer_sort = true, -- whether or not custom sorted buffers should persist
move_wraps_at_ends = false, -- whether or not the move command "wraps" at the first or last position
-- can also be a table containing 2 custom separators
-- [focused and unfocused]. eg: { '|', '|' }
--separator_style = "slant" | "slope" | "thick" | "thin" | { 'any', 'any' },
separator_style = "thin",
--enforce_regular_tabs = false | true,
enforce_regular_tabs = false,
--always_show_bufferline = true | false,
always_show_bufferline = true,
hover = {
enabled = true,
delay = 200,
reveal = {'close'}
},
--[[sort_by = 'insert_after_current' |'insert_at_end' | 'id' | 'extension' | 'relative_directory' | 'directory' | 'tabs' | function(buffer_a, buffer_b)
-- add custom logic
return buffer_a.modified > buffer_b.modified
end]]
}
}
30 changes: 30 additions & 0 deletions lua/configs/cmp.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
local status, cmp = pcall(require, "cmp")

if not status then -- The plugin is not existed
return
end

cmp.setup({
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }),
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
--{ name = 'vsnip' }, -- For vsnip users.
--{ name = 'luasnip' }, -- For luasnip users.
--{ name = 'ultisnips' }, -- For ultisnips users.
-- { name = 'snippy' }, -- For snippy users.
},
{
{ name = 'buffer' },
}),

})
57 changes: 57 additions & 0 deletions lua/configs/fidget.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
local status, fidget = pcall(require, "fidget")

if not status then -- The plugin is not existed
return
end

fidget.setup{
text = {
spinner = "pipe", -- animation shown when tasks are ongoing
done = "✔", -- character shown when all tasks are complete
commenced = "Started", -- message shown when task starts
completed = "Completed", -- message shown when task completes
},
align = {
bottom = true, -- align fidgets along bottom edge of buffer
right = true, -- align fidgets along right edge of buffer
},
timer = {
spinner_rate = 125, -- frame rate of spinner animation, in ms
fidget_decay = 2000, -- how long to keep around empty fidget, in ms
task_decay = 1000, -- how long to keep around completed task, in ms
},
window = {
relative = "win",
blend = 100,
zindex = 200,
border = "none"
},
fmt = {
max_messages = 2, -- The maximum number of messages stacked at any give time
leftpad = true, -- right-justify text in fidget box
stack_upwards = true, -- list of tasks grows upwards
max_width = 0, -- maximum width of the fidget box
fidget = -- function to format fidget title
function(fidget_name, spinner)
return string.format("%s %s", spinner, fidget_name)
end,
task = -- function to format each task line
function(task_name, message, percentage)
return string.format(
"%s%s [%s]",
message,
percentage and string.format(" (%s%%)", percentage) or "",
task_name
)
end,
},
--[[sources = { -- Sources to configure
* = { -- Name of source
ignore = false, -- Ignore notifications from this source
},
},]]
debug = {
logging = false, -- whether to enable logging, for debugging
strict = false, -- whether to interpret LSP strictly
},
}
8 changes: 8 additions & 0 deletions lua/configs/lsp.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
local status, lspconfig = pcall(require, "lspconfig")

if not status then -- The plugin is not existed
return
end

lspconfig.clangd.setup{}
lspconfig.pyright.setup{}
17 changes: 17 additions & 0 deletions lua/configs/lsp_signature.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
local status, lsp_signature = pcall(require, "lsp_signature")

if not status then -- The plugin is not existed
return
end

--require'lspconfig'.gopls.setup{}

lsp_signature.setup({
wrap = true,
floating_window = true,
floating_window_above_cur_line = true,
bind = true, -- This is mandatory, otherwise border config won't get registered.
handler_opts = {
border = "rounded"
}
})
46 changes: 46 additions & 0 deletions lua/configs/lualine.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
local status, lualine = pcall(require, 'lualine')

if not status then
return
end

lualine.setup {
options = {
icons_enabled = true,
theme = 'auto',
component_separators = { left = '', right = ''},
section_separators = { left = '', right = ''},
disabled_filetypes = {
statusline = {},
winbar = {},
},
ignore_focus = {},
always_divide_middle = true,
globalstatus = false,
refresh = {
statusline = 1000,
tabline = 1000,
winbar = 1000,
}
},
sections = {
lualine_a = {'mode'},
lualine_b = {'branch', 'diff', 'diagnostics'},
lualine_c = {'filename'},
lualine_x = {'encoding', 'fileformat', 'filetype'},
lualine_y = {'progress'},
lualine_z = {'location'}
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {'filename'},
lualine_x = {'location'},
lualine_y = {},
lualine_z = {}
},
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = {}
}
13 changes: 13 additions & 0 deletions lua/configs/mason-lsp.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
local status, mason_lsp = pcall(require, "mason-lspconfig")

if not status then -- The plugin is not existed
return
end

mason_lsp.setup({
--automatic_installation = false,
ensure_installed = {
"clangd",
"pyright",
}
})
19 changes: 19 additions & 0 deletions lua/configs/mason.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
local status, mason = pcall(require, "mason")

if not status then -- The plugin is not existed
return
end

mason.setup({
ui = {
icons = {
package_installed = "✓",
package_pending = "➜",
package_uninstalled = "✗"
},
height = 0.7, -- 0 to 1
width = 0.6,
--check_outdated_packages_on_open = true,
border = "rounded",
}
})
22 changes: 22 additions & 0 deletions lua/configs/neo-tree.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
local status, neo_tree = pcall(require, "neo-tree")

if not status then
return
end

neo_tree.setup({
close_if_last_window = true, -- Close Neo-tree if it is the last window left in the tab
icon = {
folder_closed = "",
folder_open = "",
folder_empty = "󰜌",
-- The next two settings are only a fallback, if you use nvim-web-devicons and configure default icons there
-- then these will never be used.
default = "*",
highlight = "NeoTreeFileIcon"
},
window = {
position = "left", -- location
width = 30, -- window width
},
})
Loading