dap, oil nvim

This commit is contained in:
Niktia Bykov
2024-06-20 22:55:00 +05:00
parent 6e5a434894
commit ebac03d2ff
10 changed files with 250 additions and 50 deletions

View File

@ -7,6 +7,7 @@ require("user.options")
require("user.keymaps") require("user.keymaps")
require("user.cmp") require("user.cmp")
require("user.nvim_navic")
require("user.lsp") require("user.lsp")
require("user.treesitter") require("user.treesitter")
require("user.blank_indent_highlight") require("user.blank_indent_highlight")
@ -18,9 +19,10 @@ require("user.dropbar")
require("user.nvim_scrollbar") require("user.nvim_scrollbar")
require("user.gitsigns") require("user.gitsigns")
require("user.lualine") require("user.lualine")
require("user.dap.dap")
require("user.dap.dapui") require("user.dap.dapui")
require("user.dap.dap")
require("user.neotree") require("user.neotree")
require("user.oil")
require("user.which_key") require("user.which_key")
require("user.harpoon") require("user.harpoon")

View File

@ -1,37 +1,83 @@
local dap_status_ok, dap = pcall(require, "dap") local dap_status_ok, dap = pcall(require, "dap")
if not dap_status_ok then if not dap_status_ok then
print("aaaaa")
return return
end end
local dapui_status_ok, dapui = pcall(require, "dapui") local dapui_status_ok, dapui = pcall(require, "dapui")
if not dapui_status_ok then if not dapui_status_ok then
print("fasdfasdfasdfasdf")
return return
end end
dap.adapters.coreclr = { dap.adapters.coreclr = {
type = 'executable', type = 'executable',
command = '/usr/local/netcoredbg', command = '/home/nikita/.local/share/nvim/mason/bin/netcoredbg',
args = {'--interpreter=vscode'} args = { '--interpreter=vscode' }
} }
dap.configurations.cs = { vim.g.dotnet_build_project = function()
local default_path = vim.fn.getcwd() .. '/'
if vim.g['dotnet_last_proj_path'] ~= nil then
default_path = vim.g['dotnet_last_proj_path']
end
local path = vim.fn.input('Path to your *proj file', default_path, 'file')
vim.g['dotnet_last_proj_path'] = path
local cmd = 'dotnet build -c Debug ' .. path .. ' > /dev/null'
print('')
print('Cmd to execute: ' .. cmd)
local f = os.execute(cmd)
if f == 0 then
print('\nBuild: ✔️ ')
else
print('\nBuild: ❌ (code: ' .. f .. ')')
end
end
vim.g.dotnet_get_dll_path = function()
local request = function()
return vim.fn.input('Path to dll', vim.fn.getcwd(), 'file')
end
if vim.g['dotnet_last_dll_path'] == nil then
vim.g['dotnet_last_dll_path'] = request()
else
if vim.fn.confirm('Do you want to change the path to dll?\n' .. vim.g['dotnet_last_dll_path'], '&yes\n&no', 2) == 1 then
vim.g['dotnet_last_dll_path'] = request()
end
end
return vim.g['dotnet_last_dll_path']
end
local config = {
{ {
type = "coreclr", type = "coreclr",
name = "launch - netcoredbg", name = "launch - netcoredbg",
request = "launch", request = "launch",
-- console = "integratedTerminal",
cwd = "${workspaceFolder}/src/ClientService.AspNet",
launchSettingsFilePath = "${workspaceFolder}/src/ClientService.AspNet/Properties/launchSettings.json",
launchSettingsProfile = "ClientService.AspNet",
program = function() program = function()
return vim.fn.input('Path to dll', vim.fn.getcwd() .. '/bin/Debug/', 'file') if vim.fn.confirm('Should I recompile first?', '&yes\n&no', 2) == 1 then
vim.g.dotnet_build_project()
end
return vim.g.dotnet_get_dll_path()
end, end,
}, },
} }
dap.configurations.cs = config
--Autostart ui when debugging --Autostart ui when debugging
dap.listeners.after.event_initialized["dapui_config"] = function() dap.listeners.after.event_initialized["dapui_config"] = function()
dapui.open() dapui.open()
end end
dap.listeners.before.event_terminated["dapui_config"] = function() -- dap.listeners.before.event_terminated["dapui_config"] = function()
dapui.close() -- dapui.close()
end -- end
dap.listeners.before.event_exited["dapui_config"] = function() -- dap.listeners.before.event_exited["dapui_config"] = function()
dapui.close() -- dapui.close()
end -- end

View File

@ -1,5 +1,7 @@
local mason_lspconfig = require("mason-lspconfig") local mason_lspconfig = require("mason-lspconfig")
local navic = require("nvim-navic")
mason_lspconfig.setup_handlers({ mason_lspconfig.setup_handlers({
-- The first entry (without a key) will be the default handler -- The first entry (without a key) will be the default handler
-- and will be called for each installed server that doesn't have -- and will be called for each installed server that doesn't have
@ -9,12 +11,16 @@ mason_lspconfig.setup_handlers({
on_attach = function(client, bufnr) on_attach = function(client, bufnr)
if client.name == "omnisharp" then if client.name == "omnisharp" then
client.server_capabilities.semanticTokensProvider = nil client.server_capabilities.semanticTokensProvider = nil
navic.attach(client, bufnr)
end end
end, end,
}) })
end, end,
["pylsp"] = function() ["pylsp"] = function()
require("lspconfig")["pylsp"].setup({ require("lspconfig")["pylsp"].setup({
on_attach = function(client, bufnr)
navic.attach(client, bufnr)
end,
settings = { settings = {
pylsp = { pylsp = {
plugins = { plugins = {
@ -29,6 +35,9 @@ mason_lspconfig.setup_handlers({
end, end,
["rust_analyzer"] = function() ["rust_analyzer"] = function()
require("lspconfig")["rust_analyzer"].setup({ require("lspconfig")["rust_analyzer"].setup({
on_attach = function(client, bufnr)
navic.attach(client, bufnr)
end,
settings = { settings = {
["rust-analyzer"] = { ["rust-analyzer"] = {
cargo = { cargo = {
@ -39,7 +48,11 @@ mason_lspconfig.setup_handlers({
}) })
end, end,
function(server_name) -- default handler (optional) function(server_name) -- default handler (optional)
require("lspconfig")[server_name].setup({}) require("lspconfig")[server_name].setup({
on_attach = function(client, bufnr)
navic.attach(client, bufnr)
end,
})
end, end,
-- ["omnisharp"] = function() -- ["omnisharp"] = function()
-- require("omnisharp").setup({}) -- require("omnisharp").setup({})

View File

@ -11,16 +11,16 @@ require("neoscroll").setup({
performance_mode = false, performance_mode = false,
}) })
local t = {} -- local t = {}
-- Syntax: t[keys] = {function, {function arguments}} -- -- Syntax: t[keys] = {function, {function arguments}}
t['<C-u>'] = { 'scroll', { '-vim.wo.scroll', 'true', '250' } } -- t['<C-u>'] = { 'scroll', { '-vim.wo.scroll', 'true', '250' } }
t['<C-d>'] = { 'scroll', { 'vim.wo.scroll', 'true', '250' } } -- t['<C-d>'] = { 'scroll', { 'vim.wo.scroll', 'true', '250' } }
t['<C-b>'] = { 'scroll', { '-vim.api.nvim_win_get_height(0)', 'true', '450' } } -- t['<C-b>'] = { 'scroll', { '-vim.api.nvim_win_get_height(0)', 'true', '450' } }
t['<C-f>'] = { 'scroll', { 'vim.api.nvim_win_get_height(0)', 'true', '450' } } -- t['<C-f>'] = { 'scroll', { 'vim.api.nvim_win_get_height(0)', 'true', '450' } }
t['<C-y>'] = { 'scroll', { '-0.10', 'false', '100' } } -- t['<C-y>'] = { 'scroll', { '-0.10', 'false', '100' } }
t['<C-e>'] = { 'scroll', { '0.10', 'false', '100' } } -- t['<C-e>'] = { 'scroll', { '0.10', 'false', '100' } }
t['zt'] = { 'zt', { '250' } } -- t['zt'] = { 'zt', { '250' } }
t['zz'] = { 'zz', { '250' } } -- t['zz'] = { 'zz', { '250' } }
t['zb'] = { 'zb', { '250' } } -- t['zb'] = { 'zb', { '250' } }
require('neoscroll.config').set_mappings(t) -- require('neoscroll.config').set_mappings(t)

View File

@ -0,0 +1,12 @@
local nvim_navic_status_ok, nvim_navic = pcall(require, "nvim-navic")
if not nvim_navic_status_ok then
return
end
nvim_navic.setup({
lsp = {
auto_attach = true
}
})
-- vim.o.winbar = "%t %{%v:lua.require'nvim-navic'.get_location()%}"

View File

@ -0,0 +1,113 @@
local oil_status_ok, oil = pcall(require, "scrollbar")
if not oil_status_ok then
return
end
oil.setup({
default_file_explorer = false,
columns = {
"icon",
},
-- Buffer-local options to use for oil buffers
buf_options = {
buflisted = false,
bufhidden = "hide",
},
-- Window-local options to use for oil buffers
win_options = {
wrap = false,
signcolumn = "no",
cursorcolumn = false,
foldcolumn = "0",
spell = false,
list = false,
conceallevel = 3,
concealcursor = "nvic",
},
-- Send deleted files to the trash instead of permanently deleting them (:help oil-trash)
delete_to_trash = false,
-- Skip the confirmation popup for simple operations (:help oil.skip_confirm_for_simple_edits)
skip_confirm_for_simple_edits = false,
-- Selecting a new/moved/renamed file or directory will prompt you to save changes first
-- (:help prompt_save_on_select_new_entry)
prompt_save_on_select_new_entry = true,
-- Oil will automatically delete hidden buffers after this delay
-- You can set the delay to false to disable cleanup entirely
-- Note that the cleanup process only starts when none of the oil buffers are currently displayed
cleanup_delay_ms = 2000,
lsp_file_methods = {
-- Time to wait for LSP file operations to complete before skipping
timeout_ms = 1000,
-- Set to true to autosave buffers that are updated with LSP willRenameFiles
-- Set to "unmodified" to only save unmodified buffers
autosave_changes = false,
},
-- Constrain the cursor to the editable parts of the oil buffer
-- Set to `false` to disable, or "name" to keep it on the file names
constrain_cursor = "editable",
-- Set to true to watch the filesystem for changes and reload oil
experimental_watch_for_changes = false,
-- Keymaps in oil buffer. Can be any value that `vim.keymap.set` accepts OR a table of keymap
-- options with a `callback` (e.g. { callback = function() ... end, desc = "", mode = "n" })
-- Additionally, if it is a string that matches "actions.<name>",
-- it will use the mapping at require("oil.actions").<name>
-- Set to `false` to remove a keymap
-- See :help oil-actions for a list of all available actions
keymaps = {
["g?"] = "actions.show_help",
["<CR>"] = "actions.select",
["<C-s>"] = { "actions.select", opts = { vertical = true }, desc = "Open the entry in a vertical split" },
["<C-h>"] = { "actions.select", opts = { horizontal = true }, desc = "Open the entry in a horizontal split" },
["<C-t>"] = { "actions.select", opts = { tab = true }, desc = "Open the entry in new tab" },
["<C-p>"] = "actions.preview",
["<C-c>"] = "actions.close",
["<C-l>"] = "actions.refresh",
["-"] = "actions.parent",
["_"] = "actions.open_cwd",
["`"] = "actions.cd",
["~"] = { "actions.cd", opts = { scope = "tab" }, desc = ":tcd to the current oil directory" },
["gs"] = "actions.change_sort",
["gx"] = "actions.open_external",
["g."] = "actions.toggle_hidden",
["g\\"] = "actions.toggle_trash",
},
-- Set to false to disable all of the above keymaps
use_default_keymaps = true,
view_options = {
-- Show files and directories that start with "."
show_hidden = false,
-- This function defines what is considered a "hidden" file
is_hidden_file = function(name, bufnr)
return vim.startswith(name, ".")
end,
-- This function defines what will never be shown, even when `show_hidden` is set
is_always_hidden = function(name, bufnr)
return false
end,
-- Sort file names in a more intuitive order for humans. Is less performant,
-- so you may want to set to false if you work with large directories.
natural_order = true,
sort = {
-- sort order can be "asc" or "desc"
-- see :help oil-columns to see which columns are sortable
{ "type", "asc" },
{ "name", "asc" },
},
},
-- Configuration for the floating window in oil.open_float
float = {
-- Padding around the floating window
padding = 2,
max_width = 0,
max_height = 0,
border = "rounded",
win_options = {
winblend = 0,
},
-- This is the config that will be passed to nvim_open_win.
-- Change values here to customize the layout
override = function(conf)
return conf
end,
},
})

View File

@ -18,9 +18,13 @@ vim.opt.updatetime = 300
vim.opt.ttimeoutlen = 5 vim.opt.ttimeoutlen = 5
vim.opt.signcolumn = "yes:2" vim.opt.signcolumn = "yes:2"
vim.opt.keymap = "russian-jcukenwin"
vim.opt.iminsert=0
vim.opt.imsearch=0
vim.g.netrw_banner = 0 vim.g.netrw_banner = 0
vim.cmd("set showtabline=1") -- vim.cmd("set showtabline=1")
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd("FileType", {
pattern = "cs", pattern = "cs",

View File

@ -24,10 +24,6 @@ lazy.setup({
"nvim-lua/popup.nvim", -- An implementation of the Popup API from vim in Neovim "nvim-lua/popup.nvim", -- An implementation of the Popup API from vim in Neovim
"nvim-lua/plenary.nvim", -- Useful lua functions used ny lots of plugins "nvim-lua/plenary.nvim", -- Useful lua functions used ny lots of plugins
"navarasu/onedark.nvim", "navarasu/onedark.nvim",
"morhetz/gruvbox",
"Mofiqul/dracula.nvim",
"folke/tokyonight.nvim",
"windwp/nvim-autopairs", "windwp/nvim-autopairs",
"hrsh7th/nvim-cmp", -- The completion plugin "hrsh7th/nvim-cmp", -- The completion plugin
@ -46,10 +42,18 @@ lazy.setup({
"williamboman/mason.nvim", -- simple to use language server installer "williamboman/mason.nvim", -- simple to use language server installer
"williamboman/mason-lspconfig.nvim", "williamboman/mason-lspconfig.nvim",
"neovim/nvim-lspconfig", -- enable LSP "neovim/nvim-lspconfig", -- enable LSP
-- "williamboman/nvim-lsp-installer") -- simple to use language server installer
"nvim-treesitter/nvim-treesitter-refactor", "nvim-treesitter/nvim-treesitter-refactor",
-- file explorer -- file explorer
{
'stevearc/oil.nvim',
opts = {},
-- Optional dependencies
dependencies = { "nvim-tree/nvim-web-devicons" },
init = function()
end
},
{ {
"nvim-neo-tree/neo-tree.nvim", "nvim-neo-tree/neo-tree.nvim",
branch = "v3.x", branch = "v3.x",
@ -58,15 +62,8 @@ lazy.setup({
"nvim-tree/nvim-web-devicons", "nvim-tree/nvim-web-devicons",
"MunifTanjim/nui.nvim", "MunifTanjim/nui.nvim",
} }
}, }
{ ,
"kyazdani42/nvim-tree.lua",
dependencies = {
"kyazdani42/nvim-web-devicons", -- optional, for file icons
},
tag = "nightly", -- optional, updated every week. (see issue #1193)
},
{ {
"akinsho/bufferline.nvim", "akinsho/bufferline.nvim",
version = "*", version = "*",
@ -124,7 +121,13 @@ lazy.setup({
--debugging --debugging
"mfussenegger/nvim-dap", "mfussenegger/nvim-dap",
{
"rcarriga/nvim-dap-ui", "rcarriga/nvim-dap-ui",
dependencies = {
"mfussenegger/nvim-dap",
"nvim-neotest/nvim-nio"
}
},
"nvim-lualine/lualine.nvim", "nvim-lualine/lualine.nvim",
@ -144,6 +147,9 @@ lazy.setup({
{ "SmiteshP/nvim-navic" }, { "SmiteshP/nvim-navic" },
}, },
}, },
-- {
-- "SmiteshP/nvim-navic",
-- },
{ {
"karb94/neoscroll.nvim", "karb94/neoscroll.nvim",
}, },

View File

@ -73,6 +73,10 @@ which_key.setup({
which_key.register({ which_key.register({
name = "Hotkeys", name = "Hotkeys",
o = {
":Oil --float <CR>",
"Oil nvim toggle",
},
e = { e = {
":Neotree toggle <CR>", ":Neotree toggle <CR>",
"File tree toggle", "File tree toggle",

2
.zshrc
View File

@ -15,7 +15,7 @@ zplug load
ZSH_THEME="simple" ZSH_THEME="simple"
plugins=(git jsontools vi-mode sudo) plugins=(git jsontools sudo)
zstyle ':omz:update' mode disabled zstyle ':omz:update' mode disabled
source $ZSH/oh-my-zsh.sh source $ZSH/oh-my-zsh.sh