2023-07-14 16:21:54 -04:00
|
|
|
-- theming
|
|
|
|
-- Default options
|
|
|
|
require('nightfox').setup({
|
|
|
|
options = {
|
|
|
|
-- Compiled file's destination location
|
|
|
|
compile_path = vim.fn.stdpath("cache") .. "/nightfox",
|
|
|
|
compile_file_suffix = "_compiled", -- Compiled file suffix
|
|
|
|
transparent = false, -- Disable setting background
|
|
|
|
terminal_colors = true, -- Set terminal colors (vim.g.terminal_color_*) used in `:terminal`
|
|
|
|
dim_inactive = false, -- Non focused panes set to alternative background
|
|
|
|
module_default = true, -- Default enable value for modules
|
|
|
|
},
|
|
|
|
})
|
|
|
|
vim.cmd("colorscheme carbonfox")
|
|
|
|
|
|
|
|
-- Mason setup for lsp management
|
|
|
|
require("mason").setup({
|
|
|
|
ui = {
|
|
|
|
icons = {
|
|
|
|
package_installed = "*",
|
|
|
|
package_pending = ".";
|
|
|
|
package_uninstalled = "-",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
})
|
|
|
|
require("mason-lspconfig").setup()
|
|
|
|
|
|
|
|
--https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
|
|
|
|
|
|
|
|
-- Nix language server support
|
|
|
|
require'lspconfig'.nil_ls.setup{}
|
|
|
|
|
|
|
|
-- This needs a path to the omnisharp dll provided
|
|
|
|
require'lspconfig'.omnisharp.setup {}
|
|
|
|
|
|
|
|
-- Java language server support
|
|
|
|
require'lspconfig'.java_language_server.setup{}
|
|
|
|
|
|
|
|
-- Typescript language server support
|
|
|
|
require'lspconfig'.tsserver.setup{}
|
|
|
|
|
|
|
|
-- Global lsp configuration
|
|
|
|
vim.api.nvim_create_autocmd('LspAttach', {
|
|
|
|
callback = function(args)
|
|
|
|
vim.keymap.set('n', '<C-space>', vim.lsp.buf.hover, { buffer = args.buf })
|
|
|
|
vim.keymap.set("n", "<Leader>a", vim.lsp.buf.code_action, { buffer = args.buf })
|
2023-07-16 21:20:15 -04:00
|
|
|
vim.keymap.set("n", "<M-f>", vim.lsp.buf.references, { buffer = args.buf })
|
2023-07-14 16:21:54 -04:00
|
|
|
--vim.keymap.set("n", "", vim.lsp.buf.format, { buffer = args.buf })
|
|
|
|
--vim.keymap.set("n", "", vim.lsp.buf.implementation, { buffer = args.buf })
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
-- Rust language server support
|
|
|
|
local rt = require("rust-tools")
|
|
|
|
|
|
|
|
-- https://github.com/simrat39/rust-tools.nvim#configuration
|
|
|
|
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 })
|
|
|
|
]])
|
|
|
|
|
|
|
|
--Set completeopt to have a better completion experience
|
|
|
|
-- :help completeopt
|
|
|
|
-- menuone: popup even when there's only one match
|
|
|
|
-- noinsert: Do not insert text until a selection is made
|
|
|
|
-- noselect: Do not select, force to select one from the menu
|
|
|
|
-- shortness: avoid showing extra messages when using completion
|
|
|
|
-- updatetime: set updatetime for CursorHold
|
|
|
|
vim.opt.completeopt = {'menuone', 'noselect', 'noinsert'}
|
|
|
|
vim.opt.shortmess = vim.opt.shortmess + { c = true}
|
|
|
|
vim.api.nvim_set_option('updatetime', 300)
|
|
|
|
|
|
|
|
-- Fixed column for diagnostics to appear
|
|
|
|
-- Show autodiagnostic popup on cursor hover_range
|
|
|
|
-- Goto previous / next diagnostic warning / error
|
|
|
|
-- Show inlay_hints more frequently
|
|
|
|
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 {
|
|
|
|
highlight = {
|
|
|
|
enable = true,
|
|
|
|
additional_vim_regex_highlighting=false,
|
|
|
|
},
|
|
|
|
ident = { enable = true },
|
|
|
|
rainbow = {
|
|
|
|
enable = true,
|
|
|
|
extended_mode = true,
|
|
|
|
max_file_lines = nil,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
vim.g.loaded_netrw = 1
|
|
|
|
vim.g.loaded_netrwPlugin = 1
|
|
|
|
|
|
|
|
-- set termguicolors to enable highlight groups
|
|
|
|
vim.opt.termguicolors = true
|
|
|
|
|
|
|
|
-- OR setup with some options
|
|
|
|
require("nvim-tree").setup({
|
|
|
|
sort_by = "case_sensitive",
|
|
|
|
view = {
|
|
|
|
width = 30,
|
|
|
|
},
|
|
|
|
renderer = {
|
|
|
|
group_empty = true,
|
|
|
|
},
|
2023-07-16 21:20:15 -04:00
|
|
|
--filters = {
|
|
|
|
-- dotfiles = true,
|
|
|
|
--},
|
2023-07-14 16:21:54 -04:00
|
|
|
})
|
|
|
|
|
2023-07-16 21:20:15 -04:00
|
|
|
|
|
|
|
vim.keymap.set("n", "<C-p>", function()
|
|
|
|
require("nvim-tree.api").tree.toggle()
|
|
|
|
end)
|