366 lines
11 KiB
Lua
366 lines
11 KiB
Lua
require "keymap"
|
|
require "options"
|
|
require "plugins"
|
|
require "vars"
|
|
|
|
-- Color Theme
|
|
vim.cmd [[
|
|
try
|
|
colorscheme nord
|
|
endtry
|
|
]]
|
|
|
|
-- Mason Setup
|
|
require("mason").setup({
|
|
ui = {
|
|
icons = {
|
|
package_installed = "",
|
|
package_pending = "",
|
|
package_uninstalled = "",
|
|
},
|
|
}
|
|
})
|
|
require("mason-lspconfig").setup()
|
|
|
|
-- Rust Tools Setup
|
|
local rt = require("rust-tools")
|
|
rt.setup({
|
|
server = {
|
|
on_attach = function(_, bufnr)
|
|
-- Hover actions
|
|
vim.keymap.set("n", "<C-space>", rt.hover_actions.hover_actions, { buffer = bufnr })
|
|
-- Code action groups
|
|
vim.keymap.set("n", "<Leader>a", rt.code_action_group.code_action_group, { buffer = bufnr })
|
|
end,
|
|
},
|
|
})
|
|
|
|
-- LSP Diagnostics Options Setup
|
|
local sign = function(opts)
|
|
vim.fn.sign_define(opts.name, {
|
|
texthl = opts.name,
|
|
text = opts.text,
|
|
numhl = ''
|
|
})
|
|
end
|
|
|
|
sign({name = 'DiagnosticSignError', text = ''})
|
|
sign({name = 'DiagnosticSignWarn', text = ''})
|
|
sign({name = 'DiagnosticSignHint', text = ''})
|
|
sign({name = 'DiagnosticSignInfo', text = ''})
|
|
|
|
vim.diagnostic.config({
|
|
virtual_text = false,
|
|
signs = true,
|
|
update_in_insert = true,
|
|
underline = true,
|
|
severity_sort = false,
|
|
float = {
|
|
border = 'rounded',
|
|
source = 'always',
|
|
header = '', prefix = '',
|
|
},
|
|
})
|
|
|
|
vim.cmd([[
|
|
set signcolumn=yes
|
|
autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false })
|
|
]])
|
|
|
|
-- Completion Plugin Setup
|
|
local cmp = require'cmp'
|
|
cmp.setup({
|
|
-- Enable LSP snippets
|
|
snippet = {
|
|
expand = function(args)
|
|
vim.fn["vsnip#anonymous"](args.body)
|
|
end,
|
|
},
|
|
mapping = {
|
|
['<C-p>'] = cmp.mapping.select_prev_item(),
|
|
['<C-n>'] = cmp.mapping.select_next_item(),
|
|
-- Add tab support
|
|
['<S-Tab>'] = cmp.mapping.select_prev_item(),
|
|
['<Tab>'] = cmp.mapping.select_next_item(),
|
|
['<C-S-f>'] = cmp.mapping.scroll_docs(-4),
|
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
|
['<C-Space>'] = cmp.mapping.complete(),
|
|
['<C-e>'] = cmp.mapping.close(),
|
|
['<CR>'] = cmp.mapping.confirm({
|
|
behavior = cmp.ConfirmBehavior.Insert,
|
|
select = true,
|
|
})
|
|
},
|
|
-- Installed sources:
|
|
sources = {
|
|
{ name = 'path' }, -- file paths
|
|
{ name = 'nvim_lsp', keyword_length = 3 }, -- from language server
|
|
{ name = 'nvim_lsp_signature_help'}, -- display function signatures with current parameter emphasized
|
|
{ name = 'nvim_lua', keyword_length = 2}, -- complete neovim's Lua runtime API such vim.lsp.*
|
|
{ name = 'buffer', keyword_length = 2 }, -- source current buffer
|
|
{ name = 'vsnip', keyword_length = 2 }, -- nvim-cmp source for vim-vsnip
|
|
{ name = 'calc'}, -- source for math calculation
|
|
},
|
|
window = {
|
|
completion = cmp.config.window.bordered(),
|
|
documentation = cmp.config.window.bordered(),
|
|
},
|
|
formatting = {
|
|
fields = {'menu', 'abbr', 'kind'},
|
|
format = function(entry, item)
|
|
local menu_icon ={
|
|
nvim_lsp = 'λ',
|
|
vsnip = '⋗',
|
|
buffer = 'Ω',
|
|
path = '🖫',
|
|
}
|
|
item.menu = menu_icon[entry.source.name]
|
|
return item
|
|
end,
|
|
},
|
|
})
|
|
|
|
|
|
|
|
-- Treesitter Plugin Setup
|
|
require('nvim-treesitter.configs').setup {
|
|
ensure_installed = { "bash", "c", "cpp", "javascript", "json", "lua", "python", "typescript", "tsx", "css", "rust", "java", "yaml", "markdown", "markdown_inline" },
|
|
auto_install = true,
|
|
highlight = {
|
|
enable = true,
|
|
additional_vim_regex_highlighting=false,
|
|
},
|
|
ident = { enable = true },
|
|
rainbow = {
|
|
enable = true,
|
|
extended_mode = true,
|
|
max_file_lines = nil,
|
|
}
|
|
}
|
|
|
|
-- nvim-tree Setup
|
|
-- following options are the default
|
|
-- each of these are documented in `:help nvim-tree.OPTION_NAME`
|
|
|
|
local nvimtree = require("nvim-tree")
|
|
|
|
nvimtree.setup {
|
|
on_attach = function(bufnr)
|
|
local api = require("nvim-tree.api")
|
|
|
|
local function opts(desc)
|
|
return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
|
|
end
|
|
api.config.mappings.default_on_attach(bufnr)
|
|
vim.keymap.set("n", "<space>", api.node.open.edit, opts("Open"))
|
|
end,
|
|
renderer = {
|
|
icons = {
|
|
webdev_colors = true,
|
|
git_placement = "before",
|
|
padding = " ",
|
|
symlink_arrow = " ➛ ",
|
|
show = {
|
|
file = true,
|
|
folder = true,
|
|
folder_arrow = true,
|
|
git = true,
|
|
},
|
|
glyphs = {
|
|
default = "",
|
|
symlink = "",
|
|
git = {
|
|
unstaged = "",
|
|
staged = "S",
|
|
unmerged = "",
|
|
renamed = "➜",
|
|
deleted = "",
|
|
untracked = "U",
|
|
ignored = "◌",
|
|
},
|
|
folder = {
|
|
default = "",
|
|
open = "",
|
|
empty = "",
|
|
empty_open = "",
|
|
symlink = "",
|
|
},
|
|
},
|
|
},
|
|
highlight_git = true,
|
|
root_folder_modifier = ":t",
|
|
indent_markers = {
|
|
enable = true,
|
|
},
|
|
},
|
|
hijack_directories = {
|
|
enable = true,
|
|
auto_open = true,
|
|
},
|
|
disable_netrw = true,
|
|
hijack_netrw = true,
|
|
hijack_cursor = false,
|
|
update_cwd = true,
|
|
diagnostics = {
|
|
enable = true,
|
|
icons = {
|
|
hint = "",
|
|
info = "",
|
|
warning = "",
|
|
error = "",
|
|
},
|
|
},
|
|
update_focused_file = {
|
|
enable = true,
|
|
update_cwd = true,
|
|
ignore_list = {},
|
|
},
|
|
system_open = {
|
|
cmd = nil,
|
|
args = {},
|
|
},
|
|
filters = {
|
|
dotfiles = false,
|
|
custom = {},
|
|
},
|
|
git = {
|
|
enable = true,
|
|
ignore = true,
|
|
timeout = 500,
|
|
},
|
|
view = {
|
|
width = 35,
|
|
side = "left",
|
|
float = {
|
|
quit_on_focus_loss = true,
|
|
},
|
|
},
|
|
trash = {
|
|
cmd = "trash",
|
|
require_confirm = true,
|
|
},
|
|
actions = {
|
|
open_file = {
|
|
resize_window = true,
|
|
quit_on_open = false,
|
|
window_picker = {
|
|
enable = false,
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
-- Statusline
|
|
require('lualine').setup {
|
|
options = { theme = 'nord' }
|
|
}
|
|
|
|
local status_ok, bufferline = pcall(require, "bufferline")
|
|
if not status_ok then
|
|
return
|
|
end
|
|
|
|
require('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, -- allows highlight groups to be overriden i.e. sets highlights as default
|
|
numbers = "none", -- | "ordinal" | "buffer_id" | "both" | function({ ordinal, id, lower, raise }): string,
|
|
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 = ' ',
|
|
max_name_length = 30,
|
|
max_prefix_length = 30, -- prefix used when a buffer is de-duplicated
|
|
truncate_names = true, -- whether or not tab names should be truncated
|
|
tab_size = 25,
|
|
diagnostics = "nvim_lsp",
|
|
diagnostics_update_in_insert = false, -- only applies to coc
|
|
diagnostics_update_on_event = true, -- use nvim's diagnostic handler
|
|
-- The diagnostics indicator can be set to nil to keep the buffer name highlight but delete the highlighting
|
|
offsets = {
|
|
{
|
|
filetype = "NvimTree",
|
|
text = "File Explorer",-- | function ,
|
|
text_align = "left",-- | "center" | "right"
|
|
separator = true
|
|
}
|
|
},
|
|
color_icons = true, -- whether or not to add the filetype icon highlights
|
|
show_buffer_icons = true , -- disable filetype icons for buffers
|
|
show_buffer_close_icons = true ,
|
|
show_close_icon = true,
|
|
show_tab_indicators = true ,
|
|
show_duplicate_prefix = true , -- whether to show duplicate buffer prefix
|
|
duplicates_across_groups = true, -- whether to consider duplicate paths in different groups as duplicates
|
|
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 = "thin", --| "slope" | "thick" | "thin" | { 'any', 'any' },
|
|
enforce_regular_tabs = true,--| true,
|
|
always_show_bufferline = true,-- | false,
|
|
auto_toggle_bufferline = true,-- | false,
|
|
hover = {
|
|
enabled = true,
|
|
delay = 200,
|
|
reveal = {'close'}
|
|
},
|
|
sort_by = 'insert_after_current',
|
|
}
|
|
}
|
|
|
|
-- Git sign
|
|
require("gitsigns").setup {
|
|
signs = {
|
|
add = { text = '┃' },
|
|
change = { text = '┃' },
|
|
delete = { text = '_' },
|
|
topdelete = { text = '‾' },
|
|
changedelete = { text = '~' },
|
|
untracked = { text = '┆' },
|
|
},
|
|
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
|
|
numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
|
|
linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
|
|
word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
|
|
watch_gitdir = {
|
|
interval = 1000,
|
|
follow_files = true
|
|
},
|
|
attach_to_untracked = true,
|
|
current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame`
|
|
current_line_blame_opts = {
|
|
virt_text = true,
|
|
virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align'
|
|
delay = 1000,
|
|
ignore_whitespace = false,
|
|
},
|
|
sign_priority = 6,
|
|
update_debounce = 100,
|
|
status_formatter = nil, -- Use default
|
|
max_file_length = 40000,
|
|
preview_config = {
|
|
-- Options passed to nvim_open_win
|
|
border = 'single',
|
|
style = 'minimal',
|
|
relative = 'cursor',
|
|
row = 0,
|
|
col = 1
|
|
},
|
|
}
|
|
|
|
|
|
require("presence").setup({
|
|
debounce_timeout = 5, -- Number of seconds to debounce events (or calls to `:lua package.loaded.presence:update(<filename>, true)`)
|
|
})
|