My changes
This commit is contained in:
parent
60ff3cee11
commit
fea76420c9
190
init.lua
190
init.lua
|
|
@ -114,9 +114,9 @@ vim.opt.showmode = false
|
||||||
-- Schedule the setting after `UiEnter` because it can increase startup-time.
|
-- Schedule the setting after `UiEnter` because it can increase startup-time.
|
||||||
-- Remove this option if you want your OS clipboard to remain independent.
|
-- Remove this option if you want your OS clipboard to remain independent.
|
||||||
-- See `:help 'clipboard'`
|
-- See `:help 'clipboard'`
|
||||||
vim.schedule(function()
|
-- vim.schedule(function()
|
||||||
vim.opt.clipboard = 'unnamedplus'
|
-- vim.opt.clipboard = 'unnamedplus'
|
||||||
end)
|
-- end)
|
||||||
|
|
||||||
-- Enable break indent
|
-- Enable break indent
|
||||||
vim.opt.breakindent = true
|
vim.opt.breakindent = true
|
||||||
|
|
@ -189,6 +189,39 @@ vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right win
|
||||||
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
|
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
|
||||||
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
|
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
|
||||||
|
|
||||||
|
-- Custom keymaps for yanking file paths to system clipboard (+)
|
||||||
|
vim.keymap.set('n', '<leader>yp', ":let @+=expand('%:.')<CR>", { desc = 'Copy relative path' })
|
||||||
|
vim.keymap.set('n', '<leader>yP', ':let @+=expand("%:p")<CR>', { desc = 'Copy absolute path' })
|
||||||
|
|
||||||
|
-- 1. Yanking to System Clipboard
|
||||||
|
-- In Normal Mode: <leader>yy yanks the current line
|
||||||
|
vim.keymap.set('n', '<leader>yy', [["+yy]], { desc = 'Yank line to system clipboard' })
|
||||||
|
-- In Visual Mode: <leader>y yanks the selection
|
||||||
|
vim.keymap.set('v', '<leader>y', [["+y]], { desc = 'Yank selection to system clipboard' })
|
||||||
|
-- Yank from cursor to end of line
|
||||||
|
vim.keymap.set('n', '<leader>yY', [["+y$]], { desc = 'Yank to end of line to clipboard' })
|
||||||
|
|
||||||
|
-- 2. Pasting from System Clipboard
|
||||||
|
-- Keeps <leader>p for explicit system paste
|
||||||
|
vim.keymap.set({ 'n', 'v' }, '<leader>p', [["+p]], { desc = 'Paste from system clipboard' })
|
||||||
|
vim.keymap.set({ 'n', 'v' }, '<leader>P', [["+P]], { desc = 'Paste before from system clipboard' })
|
||||||
|
|
||||||
|
-- 3. Insert Mode Paste
|
||||||
|
-- <C-p> to paste system clipboard while typing
|
||||||
|
vim.keymap.set('i', '<C-p>', '<C-r>+', { desc = 'Paste from clipboard in insert mode' })
|
||||||
|
|
||||||
|
-- 4. Select All (standard ggVG)
|
||||||
|
vim.keymap.set('n', '<C-a>', '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 ]]
|
-- [[ Basic Autocommands ]]
|
||||||
-- See `:help lua-guide-autocommands`
|
-- See `:help lua-guide-autocommands`
|
||||||
|
|
||||||
|
|
@ -229,6 +262,17 @@ vim.opt.rtp:prepend(lazypath)
|
||||||
require('lazy').setup({
|
require('lazy').setup({
|
||||||
-- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link).
|
-- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link).
|
||||||
'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically
|
'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically
|
||||||
|
{
|
||||||
|
'akinsho/toggleterm.nvim',
|
||||||
|
version = "*",
|
||||||
|
config = function()
|
||||||
|
require("toggleterm").setup({
|
||||||
|
open_mapping = [[<leader>tt]],
|
||||||
|
direction = "horizontal",
|
||||||
|
size = 10,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
},
|
||||||
|
|
||||||
-- NOTE: Plugins can also be added by using a table,
|
-- NOTE: Plugins can also be added by using a table,
|
||||||
-- with the first argument being the link and the following
|
-- 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.
|
-- 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)
|
{ -- Fuzzy Finder (files, lsp, etc)
|
||||||
'nvim-telescope/telescope.nvim',
|
'nvim-telescope/telescope.nvim',
|
||||||
event = 'VimEnter',
|
event = 'VimEnter',
|
||||||
branch = '0.1.x',
|
|
||||||
dependencies = {
|
dependencies = {
|
||||||
'nvim-lua/plenary.nvim',
|
'nvim-lua/plenary.nvim',
|
||||||
{ -- If encountering errors, see telescope-fzf-native README for installation instructions
|
{ -- If encountering errors, see telescope-fzf-native README for installation instructions
|
||||||
|
|
@ -391,6 +441,7 @@ require('lazy').setup({
|
||||||
pickers = {
|
pickers = {
|
||||||
find_files = {
|
find_files = {
|
||||||
hidden = true,
|
hidden = true,
|
||||||
|
no_ignore = true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
extensions = {
|
extensions = {
|
||||||
|
|
@ -462,7 +513,15 @@ require('lazy').setup({
|
||||||
-- Automatically install LSPs and related tools to stdpath for Neovim
|
-- 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.
|
-- 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({})`
|
-- NOTE: `opts = {}` is the same as calling `require('mason').setup({})`
|
||||||
{ 'williamboman/mason.nvim', opts = {} },
|
{
|
||||||
|
'williamboman/mason.nvim',
|
||||||
|
opts = {
|
||||||
|
registries = {
|
||||||
|
'github:mason-org/mason-registry',
|
||||||
|
'github:Crashdummyy/mason-registry',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
'williamboman/mason-lspconfig.nvim',
|
'williamboman/mason-lspconfig.nvim',
|
||||||
'WhoIsSethDaniel/mason-tool-installer.nvim',
|
'WhoIsSethDaniel/mason-tool-installer.nvim',
|
||||||
|
|
||||||
|
|
@ -620,9 +679,19 @@ require('lazy').setup({
|
||||||
-- - settings (table): Override the default settings passed when initializing the server.
|
-- - 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/
|
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
|
||||||
local servers = {
|
local servers = {
|
||||||
-- clangd = {},
|
clangd = {},
|
||||||
-- gopls = {},
|
gopls = {
|
||||||
-- pyright = {},
|
settings = {
|
||||||
|
gopls = {
|
||||||
|
analyses = {
|
||||||
|
unusedparams = true,
|
||||||
|
},
|
||||||
|
staticcheck = true,
|
||||||
|
gofumpt = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
pyright = {},
|
||||||
-- rust_analyzer = {},
|
-- rust_analyzer = {},
|
||||||
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
|
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
|
||||||
--
|
--
|
||||||
|
|
@ -630,9 +699,31 @@ require('lazy').setup({
|
||||||
-- https://github.com/pmizio/typescript-tools.nvim
|
-- https://github.com/pmizio/typescript-tools.nvim
|
||||||
--
|
--
|
||||||
-- But for many setups, the LSP (`ts_ls`) will work just fine
|
-- 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 = {
|
lua_ls = {
|
||||||
-- cmd = { ... },
|
-- cmd = { ... },
|
||||||
-- filetypes = { ... },
|
-- filetypes = { ... },
|
||||||
|
|
@ -665,6 +756,12 @@ require('lazy').setup({
|
||||||
local ensure_installed = vim.tbl_keys(servers or {})
|
local ensure_installed = vim.tbl_keys(servers or {})
|
||||||
vim.list_extend(ensure_installed, {
|
vim.list_extend(ensure_installed, {
|
||||||
'stylua', -- Used to format Lua code
|
'stylua', -- Used to format Lua code
|
||||||
|
'prettierd',
|
||||||
|
'black',
|
||||||
|
'isort',
|
||||||
|
'gopls',
|
||||||
|
'goimports',
|
||||||
|
'clang-format',
|
||||||
})
|
})
|
||||||
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
|
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
|
||||||
|
|
||||||
|
|
@ -682,7 +779,6 @@ require('lazy').setup({
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
{ -- Autoformat
|
{ -- Autoformat
|
||||||
'stevearc/conform.nvim',
|
'stevearc/conform.nvim',
|
||||||
event = { 'BufWritePre' },
|
event = { 'BufWritePre' },
|
||||||
|
|
@ -703,7 +799,7 @@ require('lazy').setup({
|
||||||
-- Disable "format_on_save lsp_fallback" for languages that don't
|
-- Disable "format_on_save lsp_fallback" for languages that don't
|
||||||
-- have a well standardized coding style. You can add additional
|
-- have a well standardized coding style. You can add additional
|
||||||
-- languages here or re-enable it for the disabled ones.
|
-- languages here or re-enable it for the disabled ones.
|
||||||
local disable_filetypes = { c = true, cpp = true }
|
local disable_filetypes = {}
|
||||||
local lsp_format_opt
|
local lsp_format_opt
|
||||||
if disable_filetypes[vim.bo[bufnr].filetype] then
|
if disable_filetypes[vim.bo[bufnr].filetype] then
|
||||||
lsp_format_opt = 'never'
|
lsp_format_opt = 'never'
|
||||||
|
|
@ -717,6 +813,14 @@ require('lazy').setup({
|
||||||
end,
|
end,
|
||||||
formatters_by_ft = {
|
formatters_by_ft = {
|
||||||
lua = { 'stylua' },
|
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
|
-- Conform can also run multiple formatters sequentially
|
||||||
-- python = { "isort", "black" },
|
-- python = { "isort", "black" },
|
||||||
--
|
--
|
||||||
|
|
@ -793,13 +897,13 @@ require('lazy').setup({
|
||||||
-- Accept ([y]es) the completion.
|
-- Accept ([y]es) the completion.
|
||||||
-- This will auto-import if your LSP supports it.
|
-- This will auto-import if your LSP supports it.
|
||||||
-- This will expand snippets if the LSP sent a snippet.
|
-- This will expand snippets if the LSP sent a snippet.
|
||||||
['<C-y>'] = cmp.mapping.confirm { select = true },
|
-- ['<C-y>'] = cmp.mapping.confirm { select = true },
|
||||||
|
|
||||||
-- If you prefer more traditional completion keymaps,
|
-- If you prefer more traditional completion keymaps,
|
||||||
-- you can uncomment the following lines
|
-- you can uncomment the following lines
|
||||||
--['<CR>'] = cmp.mapping.confirm { select = true },
|
['<CR>'] = cmp.mapping.confirm { select = true },
|
||||||
--['<Tab>'] = cmp.mapping.select_next_item(),
|
['<Tab>'] = cmp.mapping.select_next_item(),
|
||||||
--['<S-Tab>'] = cmp.mapping.select_prev_item(),
|
['<S-Tab>'] = cmp.mapping.select_prev_item(),
|
||||||
|
|
||||||
-- Manually trigger a completion from nvim-cmp.
|
-- Manually trigger a completion from nvim-cmp.
|
||||||
-- Generally you don't need this, because nvim-cmp will display
|
-- Generally you don't need this, because nvim-cmp will display
|
||||||
|
|
@ -900,30 +1004,26 @@ require('lazy').setup({
|
||||||
-- Check out: https://github.com/echasnovski/mini.nvim
|
-- Check out: https://github.com/echasnovski/mini.nvim
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
{ -- Highlight, edit, and navigate code
|
{ -- Install treesitter parsers and queries
|
||||||
'nvim-treesitter/nvim-treesitter',
|
'nvim-treesitter/nvim-treesitter',
|
||||||
|
lazy = false,
|
||||||
build = ':TSUpdate',
|
build = ':TSUpdate',
|
||||||
main = 'nvim-treesitter.configs', -- Sets main module to use for opts
|
config = function()
|
||||||
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
|
require('nvim-treesitter').setup {
|
||||||
opts = {
|
install_dir = vim.fn.stdpath('data') .. '/site',
|
||||||
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc', 'gitcommit' },
|
}
|
||||||
-- Autoinstall languages that are not installed
|
|
||||||
auto_install = true,
|
require('nvim-treesitter').install {
|
||||||
highlight = {
|
'bash', 'c', 'cpp', 'diff', 'html', 'lua', 'luadoc',
|
||||||
enable = true,
|
'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc',
|
||||||
-- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules.
|
'gitcommit', 'python', 'go', 'gomod', 'gowork', 'gosum',
|
||||||
-- 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' },
|
-- Enable treesitter highlighting via Neovim built-in
|
||||||
},
|
vim.api.nvim_create_autocmd('FileType', {
|
||||||
indent = { enable = true, disable = { 'ruby' } },
|
callback = function() pcall(vim.treesitter.start) end,
|
||||||
},
|
})
|
||||||
-- There are additional nvim-treesitter modules that you can use to interact
|
end,
|
||||||
-- 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
|
|
||||||
},
|
},
|
||||||
|
|
||||||
-- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the
|
-- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the
|
||||||
|
|
@ -939,14 +1039,14 @@ require('lazy').setup({
|
||||||
-- require 'kickstart.plugins.indent_line',
|
-- require 'kickstart.plugins.indent_line',
|
||||||
-- require 'kickstart.plugins.lint',
|
-- require 'kickstart.plugins.lint',
|
||||||
-- require 'kickstart.plugins.autopairs',
|
-- require 'kickstart.plugins.autopairs',
|
||||||
-- require 'kickstart.plugins.neo-tree',
|
require 'kickstart.plugins.neo-tree',
|
||||||
-- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
|
-- 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`
|
-- 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.
|
-- 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.
|
-- 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`
|
-- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec`
|
||||||
-- Or use telescope!
|
-- Or use telescope!
|
||||||
|
|
@ -976,3 +1076,13 @@ require('lazy').setup({
|
||||||
|
|
||||||
-- The line beneath this is called `modeline`. See `:help modeline`
|
-- The line beneath this is called `modeline`. See `:help modeline`
|
||||||
-- vim: ts=2 sts=2 sw=2 et
|
-- 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,
|
||||||
|
})
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
require('mason').setup {
|
||||||
|
registries = {
|
||||||
|
'github:mason-org/mason-registry',
|
||||||
|
'github:Crashdummyy/mason-registry',
|
||||||
|
},
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue