diff --git a/init.lua b/init.lua index 4eae8e7d95a..b257efadea7 100644 --- a/init.lua +++ b/init.lua @@ -91,7 +91,7 @@ vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -- Set to true if you have a Nerd Font installed and selected in the terminal -vim.g.have_nerd_font = false +vim.g.have_nerd_font = true -- [[ Setting options ]] -- See `:help vim.opt` @@ -102,7 +102,7 @@ vim.g.have_nerd_font = false vim.opt.number = true -- You can also add relative line numbers, to help with jumping. -- Experiment for yourself to see if you like it! --- vim.opt.relativenumber = true +vim.opt.relativenumber = true -- Enable mouse mode, can be useful for resizing splits for example! vim.opt.mouse = 'a' @@ -114,9 +114,9 @@ vim.opt.showmode = false -- Schedule the setting after `UiEnter` because it can increase startup-time. -- Remove this option if you want your OS clipboard to remain independent. -- See `:help 'clipboard'` -vim.schedule(function() - vim.opt.clipboard = 'unnamedplus' -end) +-- vim.schedule(function() +-- vim.opt.clipboard = 'unnamedplus' +-- end) -- Enable break indent vim.opt.breakindent = true @@ -189,6 +189,39 @@ vim.keymap.set('n', '', '', { desc = 'Move focus to the right win vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) +-- Custom keymaps for yanking file paths to system clipboard (+) +vim.keymap.set('n', 'yp', ":let @+=expand('%:.')", { desc = 'Copy relative path' }) +vim.keymap.set('n', 'yP', ':let @+=expand("%:p")', { desc = 'Copy absolute path' }) + +-- 1. Yanking to System Clipboard +-- In Normal Mode: yy yanks the current line +vim.keymap.set('n', 'yy', [["+yy]], { desc = 'Yank line to system clipboard' }) +-- In Visual Mode: y yanks the selection +vim.keymap.set('v', 'y', [["+y]], { desc = 'Yank selection to system clipboard' }) +-- Yank from cursor to end of line +vim.keymap.set('n', 'yY', [["+y$]], { desc = 'Yank to end of line to clipboard' }) + +-- 2. Pasting from System Clipboard +-- Keeps p for explicit system paste +vim.keymap.set({ 'n', 'v' }, 'p', [["+p]], { desc = 'Paste from system clipboard' }) +vim.keymap.set({ 'n', 'v' }, 'P', [["+P]], { desc = 'Paste before from system clipboard' }) + +-- 3. Insert Mode Paste +-- to paste system clipboard while typing +vim.keymap.set('i', '', '+', { desc = 'Paste from clipboard in insert mode' }) + +-- 4. Select All (standard ggVG) +vim.keymap.set('n', '', 'ggVG', { desc = 'Select all text' }) + +-- [[ Filetype Detection ]] +-- Recognize .cshtml files as razor (not html) to prevent incorrect formatting +vim.filetype.add { + extension = { + cshtml = 'razor', + razor = 'razor', + }, +} + -- [[ Basic Autocommands ]] -- See `:help lua-guide-autocommands` @@ -229,6 +262,17 @@ vim.opt.rtp:prepend(lazypath) require('lazy').setup({ -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically + { + 'akinsho/toggleterm.nvim', + version = "*", + config = function() + require("toggleterm").setup({ + open_mapping = [[tt]], + direction = "horizontal", + size = 10, + }) + end + }, -- NOTE: Plugins can also be added by using a table, -- with the first argument being the link and the following @@ -254,6 +298,13 @@ require('lazy').setup({ }, }, }, + { + 'seblyng/roslyn.nvim', + ft = 'cs', + opts = { + -- your configuration comes here; leave empty for default settings + }, + }, -- NOTE: Plugins can also be configured to run Lua code when they are loaded. -- @@ -336,7 +387,6 @@ require('lazy').setup({ { -- Fuzzy Finder (files, lsp, etc) 'nvim-telescope/telescope.nvim', event = 'VimEnter', - branch = '0.1.x', dependencies = { 'nvim-lua/plenary.nvim', { -- If encountering errors, see telescope-fzf-native README for installation instructions @@ -388,7 +438,12 @@ require('lazy').setup({ -- i = { [''] = 'to_fuzzy_refine' }, -- }, -- }, - -- pickers = {} + pickers = { + find_files = { + hidden = true, + no_ignore = true, + }, + }, extensions = { ['ui-select'] = { require('telescope.themes').get_dropdown(), @@ -458,7 +513,14 @@ require('lazy').setup({ -- Automatically install LSPs and related tools to stdpath for Neovim -- Mason must be loaded before its dependents so we need to set it up here. -- NOTE: `opts = {}` is the same as calling `require('mason').setup({})` - { 'williamboman/mason.nvim', opts = {} }, + { + 'williamboman/mason.nvim', + opts = { + registries = { + 'github:mason-org/mason-registry', + }, + }, + }, 'williamboman/mason-lspconfig.nvim', 'WhoIsSethDaniel/mason-tool-installer.nvim', @@ -616,9 +678,19 @@ require('lazy').setup({ -- - 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 = {}, + clangd = {}, + gopls = { + settings = { + gopls = { + analyses = { + unusedparams = true, + }, + staticcheck = true, + gofumpt = true, + }, + }, + }, + pyright = {}, -- rust_analyzer = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs -- @@ -626,9 +698,31 @@ require('lazy').setup({ -- https://github.com/pmizio/typescript-tools.nvim -- -- But for many setups, the LSP (`ts_ls`) will work just fine - -- ts_ls = {}, - -- + ts_ls = {}, + eslint = {}, + html = { + filetypes = { 'html' }, + settings = { + html = { + format = { + -- Disable the LSP formatter if you are using Prettier (recommended) + -- enable = false, + -- If you want to keep using LSP formatting, adjust these: + templating = true, -- Handle {{ }} tags decently + wrapLineLength = 120, -- Don't wrap lines too early + wrapAttributes = 'auto', -- 'auto', 'force', 'force-aligned', 'force-expand-multiline' + + -- Add elements here that you DON'T want formatted (e.g., if you use scripts inside specific tags) + unformatted = { 'script', 'style', 'pre', 'code', 'textarea' }, + + -- Sometimes helpful to prevent stripping/adding weird spaces + indentInnerHtml = true, + }, + }, + }, + }, + -- lua_ls = { -- cmd = { ... }, -- filetypes = { ... }, @@ -661,6 +755,12 @@ require('lazy').setup({ local ensure_installed = vim.tbl_keys(servers or {}) vim.list_extend(ensure_installed, { 'stylua', -- Used to format Lua code + 'prettierd', + 'black', + 'isort', + 'gopls', + 'goimports', + 'clang-format', }) require('mason-tool-installer').setup { ensure_installed = ensure_installed } @@ -678,7 +778,6 @@ require('lazy').setup({ } end, }, - { -- Autoformat 'stevearc/conform.nvim', event = { 'BufWritePre' }, @@ -699,7 +798,7 @@ require('lazy').setup({ -- 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 } + local disable_filetypes = {} local lsp_format_opt if disable_filetypes[vim.bo[bufnr].filetype] then lsp_format_opt = 'never' @@ -713,6 +812,14 @@ require('lazy').setup({ end, formatters_by_ft = { lua = { 'stylua' }, + markdown = { 'prettierd' }, + python = { 'isort', 'black' }, + json = { 'prettierd' }, + cs = { 'csharpier' }, + razor = {}, + go = { 'goimports', 'gofmt' }, + c = { 'clang-format' }, + cpp = { 'clang-format' }, -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- @@ -789,13 +896,13 @@ require('lazy').setup({ -- Accept ([y]es) the completion. -- This will auto-import if your LSP supports it. -- This will expand snippets if the LSP sent a snippet. - [''] = cmp.mapping.confirm { select = true }, + -- [''] = cmp.mapping.confirm { select = true }, -- If you prefer more traditional completion keymaps, -- you can uncomment the following lines - --[''] = cmp.mapping.confirm { select = true }, - --[''] = cmp.mapping.select_next_item(), - --[''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.confirm { select = true }, + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_prev_item(), -- Manually trigger a completion from nvim-cmp. -- Generally you don't need this, because nvim-cmp will display @@ -843,13 +950,13 @@ require('lazy').setup({ -- 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`. - 'folke/tokyonight.nvim', + 'catppuccin/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 'tokyonight-night' + vim.cmd.colorscheme 'catppuccin-mocha' -- You can configure highlights by doing something like: vim.cmd.hi 'Comment gui=none' @@ -896,30 +1003,26 @@ require('lazy').setup({ -- Check out: https://github.com/echasnovski/mini.nvim end, }, - { -- Highlight, edit, and navigate code + { -- Install treesitter parsers and queries 'nvim-treesitter/nvim-treesitter', + lazy = false, build = ':TSUpdate', - main = 'nvim-treesitter.configs', -- Sets main module to use for opts - -- [[ Configure Treesitter ]] See `:help nvim-treesitter` - opts = { - ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, - -- Autoinstall languages that are not installed - auto_install = true, - highlight = { - enable = true, - -- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules. - -- If you are experiencing weird indenting issues, add the language to - -- the list of additional_vim_regex_highlighting and disabled languages for indent. - additional_vim_regex_highlighting = { 'ruby' }, - }, - indent = { enable = true, disable = { 'ruby' } }, - }, - -- There are additional nvim-treesitter modules that you can use to interact - -- with nvim-treesitter. You should go explore a few and see what interests you: - -- - -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod` - -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context - -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects + config = function() + require('nvim-treesitter').setup { + install_dir = vim.fn.stdpath('data') .. '/site', + } + + require('nvim-treesitter').install { + 'bash', 'c', 'cpp', 'diff', 'html', 'lua', 'luadoc', + 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc', + 'gitcommit', 'python', 'go', 'gomod', 'gowork', 'gosum', + } + + -- Enable treesitter highlighting via Neovim built-in + vim.api.nvim_create_autocmd('FileType', { + callback = function() pcall(vim.treesitter.start) end, + }) + end, }, -- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the @@ -935,14 +1038,14 @@ require('lazy').setup({ -- require 'kickstart.plugins.indent_line', -- require 'kickstart.plugins.lint', -- require 'kickstart.plugins.autopairs', - -- require 'kickstart.plugins.neo-tree', + require 'kickstart.plugins.neo-tree', -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` -- This is the easiest way to modularize your config. -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, -- -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec` -- Or use telescope! @@ -972,3 +1075,13 @@ require('lazy').setup({ -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et +-- +-- Add this at the very end of your init.lua +vim.api.nvim_create_autocmd('FileType', { + pattern = { 'c', 'cpp', 'h', 'hpp' }, + callback = function() + vim.opt_local.tabstop = 2 -- Visual width of a tab + vim.opt_local.shiftwidth = 2 -- Width of an auto-indent + vim.opt_local.expandtab = true -- Convert tabs to spaces + end, +}) diff --git a/lua/custom/roslyn.lua b/lua/custom/roslyn.lua new file mode 100644 index 00000000000..07b22e1a57a --- /dev/null +++ b/lua/custom/roslyn.lua @@ -0,0 +1,5 @@ +require('mason').setup { + registries = { + 'github:mason-org/mason-registry', + }, +}