mirror of
https://github.com/ksyasuda/rice.git
synced 2025-12-07 02:53:38 -08:00
fix nvim config
This commit is contained in:
@@ -185,33 +185,33 @@ lsp_installer.on_server_ready(function(server)
|
||||
end)
|
||||
|
||||
|
||||
local servers = { 'jedi_language_server', 'bashls', 'vimls', 'yamlls', 'dockerls', 'rust_analyzer', 'clangd', 'ansiblels' }
|
||||
for _, lsp in pairs(servers) do
|
||||
require('lspconfig')[lsp].setup {
|
||||
on_attach = on_attach,
|
||||
handlers = handlers,
|
||||
flags = {
|
||||
-- This will be the default in neovim 0.7+
|
||||
debounce_text_changes = 150,
|
||||
}
|
||||
}
|
||||
end
|
||||
-- local servers = { 'jedi_language_server', 'bashls', 'vimls', 'yamlls', 'dockerls', 'rust_analyzer', 'clangd', 'ansiblels' }
|
||||
-- for _, lsp in pairs(servers) do
|
||||
-- require('lspconfig')[lsp].setup {
|
||||
-- on_attach = on_attach,
|
||||
-- handlers = handlers,
|
||||
-- flags = {
|
||||
-- -- This will be the default in neovim 0.7+
|
||||
-- debounce_text_changes = 150,
|
||||
-- }
|
||||
-- }
|
||||
-- end
|
||||
|
||||
local plugins_path = vim.fn.stdpath("data") .. "site/autoload/plug.vim"
|
||||
local dir_list = vim.fn.glob(plugins_path .. "/*", true, true)
|
||||
local library_table = {}
|
||||
for _, v in ipairs(dir_list) do
|
||||
library_table[v .. "/lua"] = true
|
||||
end
|
||||
library_table[vim.fn.expand("$VIMRUNTIME/lua")] = true
|
||||
library_table[vim.fn.stdpath("config") .. "/lua"] = true
|
||||
require('lspconfig').sumneko_lua.setup({
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = { globals = { "vim" } },
|
||||
workspace = { library = library_table },
|
||||
},
|
||||
},
|
||||
})
|
||||
-- local plugins_path = vim.fn.stdpath("data") .. "site/autoload/plug.vim"
|
||||
-- local dir_list = vim.fn.glob(plugins_path .. "/*", true, true)
|
||||
-- local library_table = {}
|
||||
-- for _, v in ipairs(dir_list) do
|
||||
-- library_table[v .. "/lua"] = true
|
||||
-- end
|
||||
-- library_table[vim.fn.expand("$VIMRUNTIME/lua")] = true
|
||||
-- library_table[vim.fn.stdpath("config") .. "/lua"] = true
|
||||
-- require('lspconfig').sumneko_lua.setup({
|
||||
-- settings = {
|
||||
-- Lua = {
|
||||
-- diagnostics = { globals = { "vim" } },
|
||||
-- workspace = { library = library_table },
|
||||
-- },
|
||||
-- },
|
||||
-- })
|
||||
|
||||
-- require 'lspconfig'.bashls.setup {}
|
||||
-- -- require 'lspconfig'.bashls.setup {}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
require("lsp_lines").register_lsp_virtual_lines()
|
||||
require("lsp_lines").setup()
|
||||
-- Disable virtual_text since it's redundant due to lsp_lines.
|
||||
vim.diagnostic.config({
|
||||
virtual_text = false,
|
||||
|
||||
@@ -1,53 +1,52 @@
|
||||
require('lualine').setup {
|
||||
|
||||
options = {
|
||||
|
||||
icons_enabled = true,
|
||||
|
||||
theme = 'codedark',
|
||||
|
||||
-- theme = 'dracula',
|
||||
|
||||
-- theme = 'horizon',
|
||||
|
||||
-- theme = 'onedark',
|
||||
|
||||
component_separators = { left = '', right = '' },
|
||||
|
||||
section_separators = { left = '', right = ''},
|
||||
|
||||
-- section_separators = { left = '', right = '' },
|
||||
|
||||
disabled_filetypes = {},
|
||||
|
||||
always_divide_middle = true,
|
||||
|
||||
},
|
||||
|
||||
sections = {
|
||||
|
||||
lualine_a = { 'mode' },
|
||||
|
||||
lualine_b = { 'branch', 'diff' },
|
||||
|
||||
lualine_c = { 'filename' },
|
||||
|
||||
lualine_x = {
|
||||
|
||||
{
|
||||
|
||||
'diagnostics',
|
||||
|
||||
'fileformat',
|
||||
|
||||
symbols = {
|
||||
|
||||
unix = '', -- e712
|
||||
|
||||
dos = '', -- e70f
|
||||
|
||||
mac = '', -- e711
|
||||
|
||||
}
|
||||
|
||||
}, 'encoding', 'fileformat', { 'filetype', colored = true, icon_only = false } },
|
||||
require('lualine').setup {
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
theme = 'codedark',
|
||||
-- theme = 'dracula',
|
||||
-- theme = 'horizon',
|
||||
-- theme = 'onedark',
|
||||
component_separators = { left = '', right = '' },
|
||||
section_separators = { left = '', right = ''},
|
||||
disabled_filetypes = {},
|
||||
always_divide_middle = true,
|
||||
},
|
||||
sections = {
|
||||
lualine_a = { 'mode' },
|
||||
lualine_b = { 'branch', 'diff' },
|
||||
lualine_c = { 'filename' },
|
||||
lualine_x = {
|
||||
{
|
||||
'diagnostics',
|
||||
'fileformat',
|
||||
symbols = {
|
||||
unix = '', -- e712
|
||||
dos = '', -- e70f
|
||||
mac = '', -- e711
|
||||
}
|
||||
}, 'encoding', 'fileformat', { 'filetype', colored = true, icon_only = false } },
|
||||
lualine_y = { 'progress' },
|
||||
lualine_z = { 'location' }
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_c = {
|
||||
{
|
||||
'filename',
|
||||
file_status = true, -- Displays file status (readonly status, modified status)
|
||||
path = 0, -- 0: Just the filename
|
||||
shorting_target = 40, -- Shortens path to leave 40 spaces in the window
|
||||
symbols = {
|
||||
modified = '[+]', -- Text to show when the file is modified.
|
||||
readonly = '[-]', -- Text to show when the file is non-modifiable or readonly.
|
||||
unnamed = '[No Name]', -- Text to show for unnamed buffers.
|
||||
}
|
||||
},
|
||||
},
|
||||
lualine_x = { 'location' },
|
||||
lualine_y = {},
|
||||
lualine_z = {}
|
||||
},
|
||||
tabline = {},
|
||||
extensions = { 'quickfix', 'fzf', 'nvim-tree', 'symbols-outline', 'fugitive' }
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
-- Setup nvim-cmp.
|
||||
local cmp = require 'cmp'
|
||||
local lspkind = require('lspkind')
|
||||
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
|
||||
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
local lspconfig = require('lspconfig')
|
||||
-- luasnip setup
|
||||
local luasnip = require 'luasnip'
|
||||
|
||||
local highlight = require('cmp.utils.highlight')
|
||||
|
||||
local has_words_before = function()
|
||||
if vim.api.nvim_buf_get_option(0, "buftype") == "prompt" then return false end
|
||||
@@ -15,6 +13,14 @@ local has_words_before = function()
|
||||
return col ~= 0 and vim.api.nvim_buf_get_text(0, line-1, 0, line-1, col, {})[1]:match("^%s*$") == nil
|
||||
end
|
||||
|
||||
lspkind.init({
|
||||
symbol_map = {
|
||||
Copilot = "",
|
||||
},
|
||||
})
|
||||
|
||||
vim.api.nvim_set_hl(0, "CmpItemKindCopilot", {fg ="#6CC644"})
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
@@ -25,17 +31,6 @@ cmp.setup({
|
||||
end,
|
||||
},
|
||||
capabilities = capabilities,
|
||||
-- mapping = {
|
||||
-- ['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
|
||||
-- ['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
|
||||
-- ['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
|
||||
-- ['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
|
||||
-- ['<C-e>'] = cmp.mapping({
|
||||
-- i = cmp.mapping.abort(),
|
||||
-- c = cmp.mapping.close(),
|
||||
-- }),
|
||||
-- ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
-- },
|
||||
mapping = {
|
||||
['<C-p>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
@@ -67,65 +62,119 @@ cmp.setup({
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true,
|
||||
},
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if has_words_before() then
|
||||
require('copilot.suggestion').accept()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
elseif not has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
|
||||
end
|
||||
-- ["<Tab>"] = cmp.mapping(function(fallback)
|
||||
-- if cmp.visible() then
|
||||
-- cmp.select_next_item()
|
||||
-- elseif has_words_before() then
|
||||
-- cmp.complete()
|
||||
-- cmp.select_next_item()
|
||||
-- elseif luasnip.expand_or_jumpable() then
|
||||
-- luasnip.expand_or_jump()
|
||||
-- else
|
||||
-- fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
|
||||
-- fallback()
|
||||
-- end
|
||||
end, { "i", "s" }),
|
||||
-- end, { "i", "s" }),
|
||||
["<Tab>"] = vim.schedule_wrap(function(fallback)
|
||||
if cmp.visible() and has_words_before() then
|
||||
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end),
|
||||
['<S-Tab>'] = cmp.mapping(function()
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
end
|
||||
end, { "i", "s"}),
|
||||
},
|
||||
window = {
|
||||
completion = {
|
||||
winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,Search:None",
|
||||
col_offset = -3,
|
||||
side_padding = 0,
|
||||
border = "rounded",
|
||||
borderchars = {
|
||||
"─",
|
||||
"│",
|
||||
"─",
|
||||
"│",
|
||||
"╭",
|
||||
"╮",
|
||||
"╯",
|
||||
"╰",
|
||||
},
|
||||
},
|
||||
documentation = {
|
||||
border = "rounded",
|
||||
borderchars = {
|
||||
"─",
|
||||
"│",
|
||||
"─",
|
||||
"│",
|
||||
"╭",
|
||||
"╮",
|
||||
"╯",
|
||||
"╰",
|
||||
},
|
||||
-- padding = 15,
|
||||
}
|
||||
},
|
||||
formatting = {
|
||||
format = lspkind.cmp_format({
|
||||
mode = 'symbol', -- show only symbol annotations
|
||||
maxwidth = 20, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
|
||||
fields = { "kind", "abbr", "menu" },
|
||||
format = function(entry, vim_item)
|
||||
local kind = require("lspkind").cmp_format({ mode = "symbol_text", maxwidth = 75 })(entry, vim_item)
|
||||
local strings = vim.split(kind.kind, "%s", { trimempty = true })
|
||||
kind.kind = " " .. strings[1] .. " "
|
||||
kind.menu = " (" .. strings[2] .. ")"
|
||||
|
||||
-- The function below will be called before any actual modifications from lspkind
|
||||
-- so that you can provide more controls on popup customization. (See [#30](https://github.com/onsails/lspkind-nvim/pull/30))
|
||||
-- before = function (entry, vim_item)
|
||||
-- ...
|
||||
-- return vim_item
|
||||
-- end
|
||||
})
|
||||
return kind
|
||||
end,
|
||||
-- format = lspkind.cmp_format({
|
||||
-- mode = 'symbol_text', -- show only symbol annotations
|
||||
-- menu = ({
|
||||
-- buffer = "[Buffer]",
|
||||
-- nvim_lsp = "[LSP]",
|
||||
-- luasnip = "[LuaSnip]",
|
||||
-- nvim_lua = "[Lua]",
|
||||
-- latex_symbols = "[Latex]",
|
||||
-- })
|
||||
-- })
|
||||
},
|
||||
sources = cmp.config.sources({
|
||||
{ name = "copilot", group_index = 2 },
|
||||
{ name = 'nvim_lsp', group_index = 2 },
|
||||
-- { name = 'vsnip' }, -- For vsnip users.
|
||||
{ name = 'nvim_lsp_signature_help', group_index = 2 },
|
||||
{ name = "path", group_index = 2 },
|
||||
{ name = 'luasnip', group_index = 2 }, -- For luasnip users.
|
||||
{
|
||||
name = 'buffer',
|
||||
option = {
|
||||
get_bufnrs = function()
|
||||
local bufs = {}
|
||||
for _, win in ipairs(vim.api.nvim_list_wins()) do
|
||||
bufs[vim.api.nvim_win_get_buf(win)] = true
|
||||
end
|
||||
return vim.tbl_keys(bufs)
|
||||
end
|
||||
}
|
||||
}
|
||||
-- { name = 'ultisnips' }, -- For ultisnips users.
|
||||
-- { name = 'snippy' }, -- For snippy users.
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
})
|
||||
}),
|
||||
sorting = {
|
||||
priority_weight = 2,
|
||||
comparators = {
|
||||
cmp.config.compare.offset,
|
||||
cmp.config.compare.exact,
|
||||
cmp.config.compare.score,
|
||||
cmp.config.compare.kind,
|
||||
cmp.config.compare.sort_text,
|
||||
cmp.config.compare.length,
|
||||
cmp.config.compare.order,
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
-- Setup lspconfig.
|
||||
-- local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||
-- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled.
|
||||
-- require('lspconfig')['bashls'].setup {
|
||||
-- capabilities = capabilities
|
||||
-- }
|
||||
-- Enable some language servers with the additional completion capabilities offered by nvim-cmp
|
||||
local lspconfig = require('lspconfig')
|
||||
local servers = { 'bashls', 'jedi_language_server', 'sqlls', 'jsonls', 'yamlls', 'vimls', 'dotls', 'dockerls' }
|
||||
for _, lsp in ipairs(servers) do
|
||||
lspconfig[lsp].setup {
|
||||
@@ -135,9 +184,9 @@ for _, lsp in ipairs(servers) do
|
||||
end
|
||||
|
||||
|
||||
-- cmp.event:on("menu_opened", function()
|
||||
-- vim.b.copilot_suggestion_hidden = true
|
||||
-- end)
|
||||
-- cmp.event:on("menu_closed", function()
|
||||
-- vim.b.copilot_suggestion_hidden = false
|
||||
-- end)
|
||||
cmp.event:on("menu_opened", function()
|
||||
vim.b.copilot_suggestion_hidden = true
|
||||
end)
|
||||
cmp.event:on("menu_closed", function()
|
||||
vim.b.copilot_suggestion_hidden = false
|
||||
end)
|
||||
|
||||
@@ -3,7 +3,7 @@ require("which-key").setup {
|
||||
marks = true, -- shows a list of your marks on ' and `
|
||||
registers = true, -- shows your registers on " in NORMAL or <C-r> in INSERT mode
|
||||
spelling = {
|
||||
enabled = false, -- enabling this will show WhichKey when pressing z= to select spelling suggestions
|
||||
enabled = true, -- enabling this will show WhichKey when pressing z= to select spelling suggestions
|
||||
suggestions = 20, -- how many suggestions should be shown in the list?
|
||||
},
|
||||
-- the presets plugin, adds help for a bunch of default keybindings in Neovim
|
||||
@@ -53,8 +53,9 @@ require("which-key").setup {
|
||||
ignore_missing = false, -- enable this to hide mappings for which you didn't specify a label
|
||||
hidden = { "<silent>", "<cmd>", "<Cmd>", "<CR>", "call", "lua", "^:", "^ "}, -- hide mapping boilerplate
|
||||
show_help = true, -- show help message on the command line when the popup is visible
|
||||
show_keys = true, -- show the key strokes for your commands
|
||||
triggers = "auto", -- automatically setup triggers
|
||||
-- triggers = {"<leader>"} -- or specify a list manually
|
||||
-- triggers = {"<leader>"}, -- or specify a list manually
|
||||
triggers_blacklist = {
|
||||
-- list of mode / prefixes that should never be hooked by WhichKey
|
||||
-- this is mostly relevant for key maps that start with a native binding
|
||||
@@ -62,4 +63,8 @@ require("which-key").setup {
|
||||
i = { "j", "k" },
|
||||
v = { "j", "k" },
|
||||
},
|
||||
disable = {
|
||||
buftypes = {},
|
||||
filetypes = { "TelescopePrompt" },
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user