Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
266 changes: 266 additions & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,142 @@ do
-- <c-e>: Hide menu
-- <c-k>: Toggle signature help
--
-- Add any additional override configuration in the following tables. Available keys are:
-- - cmd (table): Override the default command used to start the server
-- - filetypes (table): Override the default list of associated filetypes for the server
-- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features.
-- - settings (table): Override the default settings passed when initializing the server.
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
local servers = {
clangd = {},
-- gopls = {},
-- pyright = {},
rust_analyzer = {},
-- ... etc. see `:help lspconfig-all` for a list of all the pre-configured lsps
--
-- some languages (like typescript) have entire language plugins that can be useful:
-- https://github.com/pmizio/typescript-tools.nvim
--
-- but for many setups, the lsp (`tsserver`) will work just fine
-- tsserver = {},
--
jdtls = { cmd = { 'jdtls' } },
omnisharp = {},

lua_ls = {
-- cmd = {...},
-- filetypes = { ...},
-- capabilities = {},
settings = {
lua = {
completion = {
callsnippet = 'replace',
},
-- you can toggle below to ignore lua_ls's noisy `missing-fields` warnings
-- diagnostics = { disable = { 'missing-fields' } },
},
},
},
}

-- ensure the servers and tools above are installed
-- to check the current status of installed tools and/or manually install
-- other tools, you can run
-- :mason
--
-- you can press `g?` for help in this menu.
require('mason').setup()

-- you can add other tools here that you want mason to install
-- for you, so that they are available from within neovim.
local ensure_installed = vim.tbl_keys(servers or {})
vim.list_extend(ensure_installed, {
'stylua', -- used to format lua code
})
require('mason-tool-installer').setup { ensure_installed = ensure_installed }

require('mason-lspconfig').setup {
handlers = {
function(server_name)
local server = servers[server_name] or {}
-- this handles overriding only values explicitly passed
-- by the server configuration above. useful when disabling
-- certain features of an lsp (for example, turning off formatting for tsserver)
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
require('lspconfig')[server_name].setup(server)
end,
},
}
end,
},

{
'Hoffs/omnisharp-extended-lsp.nvim',
ft = 'cs', -- Only load for C# files
config = function()
require('lspconfig').omnisharp.setup {
root_dir = require('lspconfig').util.root_pattern('*.csproj', '*.sln'),
settings = {
omnisharp = {
enableEditorConfigSupport = true, -- Enable support for editorconfig
enableMsBuildLoadProjectsOnDemand = true, -- Load projects on demand (avoids excessive loading)
enableRoslynAnalyzers = false, -- Enable Roslyn analyzers
scriptFileSupport = true, -- Enable CSX script support if not needed
loggingLevel = 'debug', -- Enable debugging logs for better diagnostics
format = {
enable = false,
},
},
},
on_attach = function(_, bufnr)
vim.keymap.set('n', 'gd', require('omnisharp_extended').lsp_definition, { buffer = bufnr, desc = 'LSP: ' .. '[G]oto [D]efinition' })
vim.keymap.set('n', 'gr', require('omnisharp_extended').lsp_references, { buffer = bufnr, desc = 'LSP: ' .. '[G]oto [R]eferences' })
vim.keymap.set('n', 'gI', require('omnisharp_extended').lsp_implementation, { buffer = bufnr, desc = 'LSP: ' .. '[G]oto [I]implementation' })
vim.keymap.set('n', '<leader>D', require('omnisharp_extended').lsp_type_definition, { buffer = bufnr, desc = 'LSP: ' .. 'Type [D]efinition' })
print 'OmniSharp is ready!'
end,
}
end,
},

{ -- Autoformat
'stevearc/conform.nvim',
lazy = false,
keys = {
{
'<leader>f',
function()
require('conform').format { async = true, lsp_fallback = true }
end,
mode = '',
desc = '[F]ormat buffer',
},
},
opts = {
notify_on_error = false,
format_on_save = function(bufnr)
-- Disable "format_on_save lsp_fallback" for languages that don't
-- have a well standardized coding style. You can add additional
-- languages here or re-enable it for the disabled ones.
local disable_filetypes = { --c = true,
cpp = true,
-- java = true,
}
return {
timeout_ms = 500,
lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype],
}
end,
formatters_by_ft = {
lua = { 'stylua' },
c = { 'clang_format' },
-- Conform can also run multiple formatters sequentially
-- python = { "isort", "black" },
--
-- You can use a sub-list to tell conform to run *until* a formatter
-- is found.
-- javascript = { { "prettierd", "prettier" } },
},
-- See `:help blink-cmp-config-keymap` for defining your own keymap
preset = 'default',

Expand All @@ -863,6 +999,136 @@ do
-- Adjusts spacing to ensure icons are aligned
nerd_font_variant = 'mono',
},
config = function()
-- See `:help cmp`
local cmp = require 'cmp'
local luasnip = require 'luasnip'
luasnip.config.setup {}

cmp.setup {
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
completion = { completeopt = 'menu,menuone,noinsert' },

-- For an understanding of why these mappings were
-- chosen, you will need to read `:help ins-completion`
--
-- No, but seriously. Please read `:help ins-completion`, it is really good!
mapping = cmp.mapping.preset.insert {
-- Select the [n]ext item
['<C-n>'] = cmp.mapping.select_next_item(),
-- Select the [p]revious item
['<C-p>'] = cmp.mapping.select_prev_item(),

-- Scroll the documentation window [b]ack / [f]orward
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),

-- Accept ([y]es) the completion.
-- This will auto-import if your LSP supports it.
-- This will expand snippets if the LSP sent a snippet.
['<Tab>'] = cmp.mapping.confirm { select = true },

-- If you prefer more traditional completion keymaps,
-- you can uncomment the following lines
--['<CR>'] = cmp.mapping.confirm { select = true },
--['<Tab>'] = cmp.mapping.select_next_item(),
--['<S-Tab>'] = cmp.mapping.select_prev_item(),

-- Manually trigger a completion from nvim-cmp.
-- Generally you don't need this, because nvim-cmp will display
-- completions whenever it has completion options available.
['<C-Space>'] = cmp.mapping.complete {},

-- Think of <c-l> as moving to the right of your snippet expansion.
-- So if you have a snippet that's like:
-- function $name($args)
-- $body
-- end
--
-- <c-l> will move you to the right of each of the expansion locations.
-- <c-h> is similar, except moving you backwards.
['<C-l>'] = cmp.mapping(function()
if luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump()
end
end, { 'i', 's' }),
['<C-h>'] = cmp.mapping(function()
if luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
end
end, { 'i', 's' }),

-- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
},
sources = {
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'path' },
},
}
end,
},

{ -- You can easily change to a different colorscheme.
-- Change the name of the colorscheme plugin below, and then
-- change the command in the config to whatever the name of that colorscheme is.
--
-- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`.
'ntk148v/habamax.nvim',
priority = 1000, -- Make sure to load this before all the other start plugins.
init = function()
-- Load the colorscheme here.
-- Like many other themes, this one has different styles, and you could load
-- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
vim.cmd.colorscheme 'habamax'
vim.cmd 'hi Normal guibg=NONE ctermbg=NONE'
vim.cmd 'hi CursorLine term=bold cterm=bold guibg=NONE'
-- vim.cmd 'hi LineNr guibg=NONE'
-- You can configure highlights by doing something like:
vim.cmd.hi 'Comment gui=none'
end,
},

-- Highlight todo, notes, etc in comments
{ 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } },

{ -- Collection of various small independent plugins/modules
'echasnovski/mini.nvim',
config = function()
-- Better Around/Inside textobjects
--
-- Examples:
-- - va) - [V]isually select [A]round [)]paren
-- - yinq - [Y]ank [I]nside [N]ext [']quote
-- - ci' - [C]hange [I]nside [']quote
require('mini.ai').setup { n_lines = 500 }

-- Add/delete/replace surroundings (brackets, quotes, etc.)
--
-- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren
-- - sd' - [S]urround [D]elete [']quotes
-- - sr)' - [S]urround [R]eplace [)] [']
require('mini.surround').setup()

-- Simple and easy statusline.
-- You could remove this setup call if you don't like it,
-- and try some other statusline plugin
local statusline = require 'mini.statusline'
-- set use_icons to true if you have a Nerd Font
statusline.setup { use_icons = vim.g.have_nerd_font }

-- You can configure sections in the statusline by overriding their
-- default behavior. For example, here we set the section for
-- cursor location to LINE:COLUMN
---@diagnostic disable-next-line: duplicate-set-field
statusline.section_location = function()
return '%2l:%-2v'
end

completion = {
-- By default, you may press `<c-space>` to show the documentation.
Expand Down
Loading