mirror of
https://github.com/js0ny/dotfiles.git
synced 2025-12-21 16:53:00 +00:00
feat(nvim): Completions and UIs
This commit is contained in:
parent
2a76a6fbe4
commit
9076795c4f
13 changed files with 147 additions and 58 deletions
|
|
@ -34,11 +34,10 @@ return {
|
|||
dashboard.section.buttons.val.leader = "SPC"
|
||||
dashboard.section.buttons.val = {
|
||||
-- leader = "SPC",
|
||||
dashboard.button('c', ' 新建文件', ':enew<CR>'),
|
||||
dashboard.button('SPC f f', ' 查找文件', ':Telescope find_files<CR>'),
|
||||
dashboard.button('SPC f h', ' 历史文件', ':Telescope oldfiles<CR>'),
|
||||
dashboard.button('SPC s l', ' 加载会话', ':SessionSearch<CR>'),
|
||||
dashboard.button('SPC f c', ' 转到设置', ':Telescope find_files cwd=~/.config/nvim<CR>'),
|
||||
dashboard.button('p', ' 查找项目', ':Telescope projects<CR>'),
|
||||
dashboard.button('h', ' 历史文件', ':Telescope oldfiles<CR>'),
|
||||
dashboard.button('l', ' 加载会话', ':SessionSearch<CR>'),
|
||||
dashboard.button('c', ' 转到设置', ':Telescope find_files cwd=~/.config/nvim<CR>'),
|
||||
dashboard.button('SPC q', ' 退出', ':qa<CR>'),
|
||||
}
|
||||
local handle = io.popen('fortune')
|
||||
|
|
|
|||
|
|
@ -122,21 +122,22 @@ ins_left {
|
|||
padding = { right = 1 },
|
||||
}
|
||||
|
||||
ins_left {
|
||||
-- filesize component
|
||||
'filesize',
|
||||
cond = conditions.buffer_not_empty,
|
||||
}
|
||||
-- ins_left {
|
||||
-- -- filesize component
|
||||
-- 'filesize',
|
||||
-- cond = conditions.buffer_not_empty,
|
||||
-- }
|
||||
|
||||
ins_left {
|
||||
'filename',
|
||||
cond = conditions.buffer_not_empty,
|
||||
color = { fg = colors.magenta, gui = 'bold' },
|
||||
}
|
||||
-- ins_left {
|
||||
-- 'filename',
|
||||
-- cond = conditions.buffer_not_empty,
|
||||
-- color = { fg = colors.magenta, gui = 'bold' },
|
||||
-- }
|
||||
|
||||
ins_left { 'location' }
|
||||
|
||||
ins_left { 'progress', color = { fg = colors.fg, gui = 'bold' } }
|
||||
-- ins_left { 'location' }
|
||||
|
||||
ins_right { 'progress', color = { fg = colors.fg, gui = 'bold' } }
|
||||
|
||||
ins_left {
|
||||
'diagnostics',
|
||||
|
|
@ -149,14 +150,21 @@ ins_left {
|
|||
},
|
||||
}
|
||||
|
||||
-- Insert mid section. You can make any number of sections in neovim :)
|
||||
-- for lualine it's any number greater then 2
|
||||
ins_left {
|
||||
function()
|
||||
return '%='
|
||||
return vim.bo.filetype
|
||||
end,
|
||||
color = { fg = colors.blue, gui = 'bold' },
|
||||
}
|
||||
|
||||
ins_left {
|
||||
function()
|
||||
return vim.bo.shiftwidth .. " space"
|
||||
end,
|
||||
}
|
||||
|
||||
|
||||
|
||||
ins_left {
|
||||
-- Lsp server name .
|
||||
function()
|
||||
|
|
@ -174,10 +182,18 @@ ins_left {
|
|||
end
|
||||
return msg
|
||||
end,
|
||||
icon = ' LSP:',
|
||||
icon = ' ',
|
||||
color = { fg = '#ffffff', gui = 'bold' },
|
||||
}
|
||||
|
||||
-- Insert mid section. You can make any number of sections in neovim :)
|
||||
-- for lualine it's any number greater then 2
|
||||
ins_left {
|
||||
function()
|
||||
return '%='
|
||||
end,
|
||||
}
|
||||
|
||||
-- Add components to right sections
|
||||
ins_right {
|
||||
'o:encoding', -- option component same as &encoding in viml
|
||||
|
|
@ -199,6 +215,7 @@ ins_right {
|
|||
color = { fg = colors.violet, gui = 'bold' },
|
||||
}
|
||||
|
||||
|
||||
ins_right {
|
||||
'diff',
|
||||
-- Is it me or the symbol for modified us really weird
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
|
||||
--- Available LSP goes here
|
||||
--- Check https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md
|
||||
--- for available server and name
|
||||
|
||||
|
||||
local function set_keymaps(keymaps_cmp)
|
||||
local mappings = {}
|
||||
for _, map in ipairs(keymaps_cmp) do
|
||||
mappings[map.keys] = map.cmd
|
||||
end
|
||||
return mappings
|
||||
end
|
||||
|
||||
return {
|
||||
"hrsh7th/nvim-cmp",
|
||||
|
|
@ -19,56 +20,47 @@ return {
|
|||
config = function()
|
||||
local cmp = require("cmp")
|
||||
local lspconfig = require("lspconfig")
|
||||
local capabitilies = require("cmp_nvim_lsp").default_capabilities()
|
||||
local servers = require("config.servers").servers
|
||||
local servers_config = require("config.servers").server_config
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
local servers_module = require("config.servers")
|
||||
local servers = servers_module.servers
|
||||
local servers_config = servers_module.server_config
|
||||
-- 默认 LSP 配置
|
||||
local default_server_config = {
|
||||
capabilities = capabitilies,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
|
||||
local raw_keymaps = require("keymaps").cmp_nvim_keymaps(cmp.mapping)
|
||||
local mapped = set_keymaps(raw_keymaps)
|
||||
-- 配置 nvim-cmp
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require("luasnip").lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
|
||||
sources = cmp.config.sources(
|
||||
-- This order defines the priority of sources.
|
||||
{
|
||||
mapping = cmp.mapping.preset.insert(mapped),
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "luasnip" },
|
||||
},
|
||||
{
|
||||
}, {
|
||||
{ name = "buffer" },
|
||||
{ name = "path" },
|
||||
}
|
||||
),
|
||||
}),
|
||||
})
|
||||
local keymaps = require("keymaps")
|
||||
local keymaps_cmp = keymaps.cmp_nvim_keymaps(cmp.mapping)
|
||||
|
||||
local function set_keymaps()
|
||||
local mappings = {}
|
||||
for _, map in ipairs(keymaps_cmp) do
|
||||
mappings[map.keys] = map.cmd
|
||||
end
|
||||
return mappings
|
||||
end
|
||||
cmp.setup.mapping = cmp.mapping.preset.insert(set_keymaps())
|
||||
-- 配置 cmdline 模式
|
||||
cmp.setup.cmdline(":", {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = {
|
||||
{ name = "cmdline" },
|
||||
-- Use `path` is slow under WSL since WSL loads Windows paths
|
||||
-- https://github.com/zsh-users/zsh-syntax-highlighting/issues/790
|
||||
-- { name = "path" },
|
||||
}
|
||||
-- path completion is slow under WSL
|
||||
-- Since WSL loads Windows Environment Variables
|
||||
},
|
||||
})
|
||||
|
||||
-- 配置 LSP
|
||||
for _, server in ipairs(servers) do
|
||||
local config = servers_config[server] or {}
|
||||
config = vim.tbl_extend("force", default_server_config, config)
|
||||
local config = vim.tbl_deep_extend("force", default_server_config, servers_config[server] or {})
|
||||
lspconfig[server].setup(config)
|
||||
end
|
||||
end,
|
||||
|
|
|
|||
15
.config/nvim/lua/plugins/mod/projects.lua
Normal file
15
.config/nvim/lua/plugins/mod/projects.lua
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
return {
|
||||
"ahmedkhalf/project.nvim",
|
||||
config = function()
|
||||
require("project_nvim").setup({
|
||||
detection_methods = { "lsp", "pattern" },
|
||||
patterns = { ".git", "Makefile", "package.json" },
|
||||
sync_root_with_cwd = true,
|
||||
silent_chdir = true,
|
||||
scope_chdir = "global",
|
||||
})
|
||||
|
||||
require("telescope").load_extension("projects")
|
||||
end,
|
||||
dependencies = { "nvim-telescope/telescope.nvim" },
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@ return {
|
|||
show_file_path = true,
|
||||
show_symbols = true,
|
||||
colors = {
|
||||
path = '',
|
||||
path = '#9c1d91',
|
||||
file_name = '',
|
||||
symbols = '',
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue