more restructure
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
require('Comment').setup({
|
||||
mappings = false,
|
||||
})
|
||||
require('legendary').keymap(
|
||||
{
|
||||
'<c-c>',
|
||||
{
|
||||
n = '<Plug>(comment_toggle_linewise_current)',
|
||||
v = '<Plug>(comment_toggle_linewise_visual)gv'
|
||||
},
|
||||
description = 'Toggle comment'
|
||||
}
|
||||
)
|
||||
@@ -1,9 +0,0 @@
|
||||
require('gitsigns').setup({
|
||||
current_line_blame = false,
|
||||
current_line_blame_opts = {
|
||||
virt_text = true,
|
||||
virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align'
|
||||
delay = 1000,
|
||||
ignore_whitespace = false,
|
||||
},
|
||||
})
|
||||
@@ -1,12 +0,0 @@
|
||||
local opt = vim.opt -- to set options
|
||||
opt.listchars:append('eol:↴')
|
||||
-- opt.listchars:append("space: ")
|
||||
opt.listchars:append('trail: ')
|
||||
opt.listchars:append('tab:→ ')
|
||||
|
||||
require('indent_blankline').setup({
|
||||
show_end_of_line = true,
|
||||
use_treesitter = true,
|
||||
show_current_context = true,
|
||||
context_patterns = { 'class', 'function', 'method', 'block', '^if', '^for', '^while' },
|
||||
})
|
||||
@@ -1,29 +0,0 @@
|
||||
vim.opt.laststatus = 3
|
||||
require('lualine').setup({
|
||||
options = {
|
||||
theme = 'gruvbox-flat',
|
||||
disabled_filetypes = {
|
||||
statusline = {},
|
||||
winbar = { 'dap-repl', 'dapui_console' },
|
||||
},
|
||||
},
|
||||
sections = { lualine_c = { 'getcwd', { 'filename', path = 1, file_status = true } } },
|
||||
inactive_sections = { lualine_c = { 'getcwd', { 'filename', path = 1, file_status = true } } },
|
||||
globalstatus = true,
|
||||
winbar = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_c = { { 'filename', path = 1, file_status = true } },
|
||||
lualine_x = {},
|
||||
lualine_y = {},
|
||||
lualine_z = {}
|
||||
},
|
||||
inactive_winbar = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_c = { { 'filename', path = 1, file_status = true } },
|
||||
lualine_x = {},
|
||||
lualine_y = {},
|
||||
lualine_z = {}
|
||||
},
|
||||
})
|
||||
@@ -1,141 +0,0 @@
|
||||
local cmp = require('cmp')
|
||||
local luasnip = require('luasnip')
|
||||
|
||||
local t = function(str)
|
||||
return vim.api.nvim_replace_termcodes(str, true, true, true)
|
||||
end
|
||||
|
||||
local check_back_space = function()
|
||||
local col = vim.fn.col('.') - 1
|
||||
return col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') ~= nil
|
||||
end
|
||||
|
||||
cmp.setup({
|
||||
formatting = {
|
||||
format = require('lspkind').cmp_format({
|
||||
mode = 'symbol_text', -- show only symbol annotations
|
||||
maxwidth = 80, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
|
||||
ellipsis_char = '...', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first)
|
||||
})
|
||||
},
|
||||
mapping = {
|
||||
['<Up>'] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c', 's' }),
|
||||
['<Down>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c', 's' }),
|
||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c', 's' }),
|
||||
['<C-e>'] = cmp.mapping(cmp.mapping.close(), { 'i', 'c', 's' }),
|
||||
['<CR>'] = cmp.mapping({
|
||||
i = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = false }),
|
||||
c = cmp.mapping.confirm({ select = false }),
|
||||
s = cmp.mapping.confirm({ select = false }),
|
||||
}),
|
||||
['<Tab>'] = cmp.mapping(function(fallback)
|
||||
if luasnip.expand_or_jumpable() then
|
||||
vim.api.nvim_feedkeys(t('<Plug>luasnip-expand-or-jump'), '', true)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, {
|
||||
'i',
|
||||
's',
|
||||
}),
|
||||
['<S-Tab>'] = cmp.mapping(function(fallback)
|
||||
if luasnip.jumpable(-1) then
|
||||
vim.api.nvim_feedkeys(t('<Plug>luasnip-jump-prev'), '', true)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, {
|
||||
'i',
|
||||
's',
|
||||
}),
|
||||
},
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require('luasnip').lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
sources = {
|
||||
{ name = 'luasnip', priority = 8 },
|
||||
{ name = 'nvim_lsp', priority = 7 },
|
||||
{ name = 'nvim_lsp_signature_help', priority = 7 },
|
||||
{ name = 'treesitter', priority = 6 },
|
||||
{ name = 'buffer', priority = 5,
|
||||
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 = 'nvim_lua' },
|
||||
-- { name = 'look' },
|
||||
-- { name = 'path' },
|
||||
-- { name = 'cmp_tabnine' },
|
||||
-- { name = 'calc' },
|
||||
-- { name = 'spell' },
|
||||
-- { name = 'emoji' },
|
||||
},
|
||||
enabled = function()
|
||||
return vim.api.nvim_buf_get_option(0, "buftype") ~= "prompt"
|
||||
or vim.api.nvim_buf_get_option(0, 'filetype') == 'dap-repl'
|
||||
or vim.api.nvim_buf_get_option(0, 'filetype') == 'dapui_watches'
|
||||
or vim.api.nvim_buf_get_option(0, 'filetype') == 'dapui_hover'
|
||||
end,
|
||||
completion = { completeopt = 'menu,menuone,noinsert, noselect' },
|
||||
window = {
|
||||
-- completion = cmp.config.window.bordered(),
|
||||
-- documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
sorting = {
|
||||
comparators = {
|
||||
require('clangd_extensions.cmp_scores'),
|
||||
cmp.config.compare.locality,
|
||||
-- cmp.config.compare.recently_used,
|
||||
-- -- cmp.config.compare.offset,
|
||||
-- cmp.config.compare.exact,
|
||||
-- cmp.config.compare.recently_used,
|
||||
-- cmp.config.compare.kind,
|
||||
-- cmp.config.compare.sort_text,
|
||||
-- cmp.config.compare.length,
|
||||
-- cmp.config.compare.order,
|
||||
},
|
||||
},
|
||||
-- experimental = { native_menu = true }
|
||||
})
|
||||
|
||||
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline('/', {
|
||||
sources = {
|
||||
{ name = 'buffer' },
|
||||
},
|
||||
})
|
||||
|
||||
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline(':', {
|
||||
sources = {
|
||||
{ name = 'cmdline' },
|
||||
{ name = 'cmdline_history' },
|
||||
{ name = 'path' },
|
||||
{ name = 'buffer' },
|
||||
},
|
||||
})
|
||||
|
||||
require('cmp').setup.filetype({ 'dap-repl', 'dapui_watches', 'dapui_hover' }, {
|
||||
sources = {
|
||||
{ name = 'dap' },
|
||||
},
|
||||
})
|
||||
|
||||
-- Autopairs
|
||||
--require("nvim-autopairs.completion.cmp").setup({
|
||||
-- map_cr = true,
|
||||
-- map_complete = true,
|
||||
-- auto_select = true
|
||||
--})
|
||||
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
|
||||
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } }))
|
||||
@@ -1,218 +0,0 @@
|
||||
require('mason').setup()
|
||||
require('mason-lspconfig').setup({
|
||||
automatic_installation = false,
|
||||
})
|
||||
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
|
||||
|
||||
OpenDiagFloat = function()
|
||||
for _, winid in pairs(vim.api.nvim_tabpage_list_wins(0)) do
|
||||
if vim.api.nvim_win_get_config(winid).zindex then
|
||||
return
|
||||
end
|
||||
end
|
||||
vim.diagnostic.open_float({ focusable = false, width=80 })
|
||||
end
|
||||
|
||||
local on_attach = function(client, bufnr)
|
||||
local function buf_set_option(...)
|
||||
vim.api.nvim_buf_set_option(bufnr, ...)
|
||||
end
|
||||
|
||||
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
vim.api.nvim_buf_set_option(0, 'formatexpr', 'v:lua.vim.lsp.formatexpr()')
|
||||
|
||||
-- Mappings.
|
||||
local opts = { noremap = true, silent = false, buffer = bufnr }
|
||||
vim.keymap.set('n', '<space>,', vim.diagnostic.goto_prev, opts)
|
||||
vim.keymap.set('n', '<space>;', vim.diagnostic.goto_next, opts)
|
||||
vim.keymap.set('n', '<space>a', vim.lsp.buf.code_action, opts)
|
||||
vim.keymap.set('n', '<space>d', vim.lsp.buf.definition, opts)
|
||||
vim.keymap.set('n', '<space>e', vim.lsp.buf.declaration, opts)
|
||||
vim.keymap.set('n', '<space>h', vim.lsp.buf.hover, opts)
|
||||
vim.keymap.set('n', '<space>c', vim.lsp.buf.outgoing_calls, opts)
|
||||
vim.keymap.set('n', '<space>C', vim.lsp.buf.incoming_calls, opts)
|
||||
vim.keymap.set('n', '<space>m', vim.lsp.buf.rename, opts)
|
||||
local tele_builtins = require('telescope.builtin')
|
||||
vim.keymap.set('n', '<C-t>', tele_builtins.lsp_dynamic_workspace_symbols, opts)
|
||||
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts)
|
||||
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
|
||||
vim.keymap.set('n', '<space>r', tele_builtins.lsp_references, opts)
|
||||
vim.keymap.set('n', '<A-m>', '<cmd>Telescope aerial<cr>', opts)
|
||||
vim.keymap.set('n', '<space>v', function() tele_builtins.diagnostics({ bufnr = 0 }) end, opts)
|
||||
vim.keymap.set('n', '<A-o>', '<cmd>ClangdSwitchSourceHeader<CR>', opts)
|
||||
|
||||
vim.cmd([[autocmd CursorHold <buffer> lua OpenDiagFloat()]])
|
||||
|
||||
-- Set some keybinds conditional on server capabilities
|
||||
if client.server_capabilities.documentFormattingProvider then
|
||||
vim.keymap.set('n', '<space>f', vim.lsp.buf.format, opts)
|
||||
end
|
||||
if client.server_capabilities.documentRangeFormattingProvider then
|
||||
vim.keymap.set('x', '<space>f', vim.lsp.buf.format, opts)
|
||||
end
|
||||
|
||||
-- Set autocommands conditional on server_capabilities
|
||||
if client.server_capabilities.documentHighlightProvider then
|
||||
vim.api.nvim_set_hl(
|
||||
0,
|
||||
"LspReferenceText",
|
||||
{ bold = true,
|
||||
ctermbg = 'red',
|
||||
bg = "#5a524c"}
|
||||
)
|
||||
vim.api.nvim_set_hl(
|
||||
0,
|
||||
"LspReferenceRead",
|
||||
{ bold = true,
|
||||
ctermbg = 'red',
|
||||
bg = 'DarkGreen' }
|
||||
)
|
||||
vim.api.nvim_set_hl(
|
||||
0,
|
||||
"LspReferenceWrite",
|
||||
{ bold = true,
|
||||
ctermbg = 'red',
|
||||
bg = 'DarkRed' }
|
||||
)
|
||||
vim.api.nvim_create_augroup("lsp_document_highlight", { clear = true })
|
||||
vim.api.nvim_clear_autocmds { buffer = bufnr, group = "lsp_document_highlight" }
|
||||
vim.api.nvim_create_autocmd("CursorHold", {
|
||||
callback = vim.lsp.buf.document_highlight,
|
||||
buffer = bufnr,
|
||||
group = "lsp_document_highlight",
|
||||
desc = "Document Highlight",
|
||||
})
|
||||
vim.api.nvim_create_autocmd("CursorMoved", {
|
||||
callback = vim.lsp.buf.clear_references,
|
||||
buffer = bufnr,
|
||||
group = "lsp_document_highlight",
|
||||
desc = "Clear All the References",
|
||||
})
|
||||
end
|
||||
|
||||
require('lsp_signature').on_attach({
|
||||
bind = true, -- This is mandatory, otherwise border config won't get registered.
|
||||
handler_opts = {
|
||||
border = 'single',
|
||||
},
|
||||
hi_parameter = 'IncSearch',
|
||||
}, bufnr)
|
||||
end
|
||||
|
||||
require('lspconfig')['pyright'].setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
}
|
||||
|
||||
require('lspconfig')['groovyls'].setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
}
|
||||
|
||||
require('lspconfig')['cmake'].setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
}
|
||||
|
||||
local clangd_capabilities = capabilities
|
||||
clangd_capabilities.textDocument.semanticHighlighting = true
|
||||
clangd_capabilities.offsetEncoding = { "utf-16" }
|
||||
require("clangd_extensions").setup {
|
||||
server = {
|
||||
capabilities = clangd_capabilities,
|
||||
on_attach = on_attach,
|
||||
cmd = { 'clangd', '--compile-commands-dir=build_nvim' },
|
||||
root_dir = require('lspconfig').util.root_pattern(
|
||||
'.clangd',
|
||||
'.clang-tidy',
|
||||
'.clang-format',
|
||||
'compile_commands.json',
|
||||
'compile_flags.txt',
|
||||
'configure.ac',
|
||||
'.git',
|
||||
'build_nvim'
|
||||
)
|
||||
},
|
||||
extensions =
|
||||
{
|
||||
inlay_hints = {
|
||||
-- Only show inlay hints for the current line
|
||||
only_current_line = true,
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
-- require('clangd_extensions').setup({
|
||||
-- server = {
|
||||
-- on_attach = on_attach,
|
||||
-- capabilities = capabilities,
|
||||
-- cmd = { 'clangd', '--compile-commands-dir=build_nvim' },
|
||||
-- },
|
||||
-- })
|
||||
|
||||
require('lspconfig')['jsonls'].setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
}
|
||||
|
||||
local lua_rtp = vim.split(package.path, ';')
|
||||
table.insert(lua_rtp, 'lua/?.lua')
|
||||
table.insert(lua_rtp, 'lua/?/init.lua')
|
||||
require('lspconfig').sumneko_lua.setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
||||
version = 'LuaJIT',
|
||||
-- Setup your lua path
|
||||
path = lua_rtp,
|
||||
},
|
||||
diagnostics = {
|
||||
-- Get the language server to recognize the `vim` global
|
||||
globals = { 'vim', 'use' },
|
||||
},
|
||||
workspace = {
|
||||
-- Make the server aware of Neovim runtime files
|
||||
library = vim.api.nvim_get_runtime_file('', true),
|
||||
},
|
||||
-- Do not send telemetry data containing a randomized but unique identifier
|
||||
telemetry = {
|
||||
enable = false,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
require('lspconfig')['dockerls'].setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
}
|
||||
|
||||
require('lspconfig')['yamlls'].setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
settings = {
|
||||
yaml = {
|
||||
validate = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
local null_ls = require('null-ls')
|
||||
null_ls.setup({
|
||||
sources = {
|
||||
null_ls.builtins.code_actions.gitsigns,
|
||||
null_ls.builtins.formatting.autopep8,
|
||||
null_ls.builtins.formatting.prettier,
|
||||
null_ls.builtins.diagnostics.flake8,
|
||||
null_ls.builtins.formatting.isort,
|
||||
null_ls.builtins.formatting.cmake_format,
|
||||
},
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
})
|
||||
|
||||
vim.diagnostic.config({ virtual_text = false })
|
||||
@@ -1,17 +0,0 @@
|
||||
require('project_nvim').setup({
|
||||
silent_chdir = true,
|
||||
ignore_lsp = { 'null-ls', 'cmake' },
|
||||
patterns = { ".git", "_darcs", ".hg", ".bzr", ".svn", "Makefile", "package.json", "build_nvim", "real_path.txt" },
|
||||
})
|
||||
require('telescope').load_extension('projects')
|
||||
require('legendary').keymaps(
|
||||
{
|
||||
{
|
||||
'<space>p',
|
||||
function ()
|
||||
require('telescope').extensions.projects.projects()
|
||||
end,
|
||||
description = 'Select project',
|
||||
},
|
||||
}
|
||||
)
|
||||
Reference in New Issue
Block a user