add dap and lsp now works properly

This commit is contained in:
juan 2021-09-27 11:56:17 +08:00
parent 8b8a626c12
commit 97c865358f
Signed by: juan
GPG Key ID: 5C1E5093C74F1DC7
5 changed files with 126 additions and 22 deletions

View File

@ -23,19 +23,21 @@ vim.api.nvim_set_keymap('i', '?', '?<c-g>u', {noremap = true})
-- plugin mappings
-- toggle NvimTree
vim.api.nvim_set_keymap('', '<C-n>', ':NvimTreeToggle<cr>', {})
vim.api.nvim_set_keymap('', '<C-n>', ':NvimTreeToggle<cr>', {silent = true})
-- toggle formatter
vim.api.nvim_set_keymap('', '<leader>fm', ':Neoformat<cr>', {})
vim.api.nvim_set_keymap('', '<leader>/', ':CommentToggle<cr>', {})
vim.api.nvim_set_keymap('', '<leader>r', ':SnipRun<cr>', {})
vim.api.nvim_set_keymap('', '<leader>b', ':HopWordBC<cr>', {})
vim.api.nvim_set_keymap('', '<leader>w', ':HopWordAC<cr>', {})
vim.api.nvim_set_keymap('', '<leader>k', ':HopLineStartBC<cr>', {})
vim.api.nvim_set_keymap('', '<leader>j', ':HopLineStartAC<cr>', {})
vim.api.nvim_set_keymap('', '<leader>tf', ':Telescope fd<cr>', {})
vim.api.nvim_set_keymap('', '<leader>tb', ':Telescope buffers<cr>', {})
vim.api.nvim_set_keymap('', '<leader>tq', ':Telescope quickfix<cr>', {})
vim.api.nvim_set_keymap('', '<leader>fm', ':Neoformat<cr>', {silent = true})
vim.api.nvim_set_keymap('', '<leader>/', ':CommentToggle<cr>', {silent = true})
vim.api.nvim_set_keymap('', '<leader>r', ':SnipRun<cr>', {silent = true})
vim.api.nvim_set_keymap('', '<leader>b', ':HopWordBC<cr>', {silent = true})
vim.api.nvim_set_keymap('', '<leader>w', ':HopWordAC<cr>', {silent = true})
vim.api.nvim_set_keymap('', '<leader>k', ':HopLineStartBC<cr>', {silent = true})
vim.api.nvim_set_keymap('', '<leader>j', ':HopLineStartAC<cr>', {silent = true})
vim.api.nvim_set_keymap('', '<leader>tf', ':Telescope fd<cr>', {silent = true})
vim.api.nvim_set_keymap('', '<leader>tb', ':Telescope buffers<cr>', {silent = true})
vim.api.nvim_set_keymap('', '<leader>tq', ':Telescope quickfix<cr>', {silent = true})
vim.api.nvim_set_keymap('', '<leader>tdd',
':Telescope lsp_document_diagnostics<cr>', {})
':Telescope lsp_document_diagnostics<cr>', {silent = true})
vim.api.nvim_set_keymap('', '<leader>tdw',
':Telescope lsp_workspace_diagnostics<cr>', {})
':Telescope lsp_workspace_diagnostics<cr>', {silent = true})
vim.api.nvim_set_keymap('', '<leader>dt', ':lua require("dapui").toggle()<cr>', {silent = true})
vim.api.nvim_set_keymap('', '<leader>de', ':lua require("dapui").eval()<cr>', {silent = true})

View File

@ -33,6 +33,14 @@ return require('packer').startup(function(use)
}
-- lsp stuff
use {'neovim/nvim-lspconfig', event = "VimEnter"}
use {
'kabouzeid/nvim-lspinstall',
config = function() require "plugins.lspinstall" end,
after = 'nvim-lspconfig'
}
-- tree sitter
use {
'nvim-treesitter/nvim-treesitter',
event = 'VimEnter',
@ -44,10 +52,12 @@ return require('packer').startup(function(use)
after = "nvim-treesitter",
config = function() require('spellsitter').setup() end
}
-- completer
use {
'ms-jpq/coq_nvim',
branch = 'coq',
event = 'VimEnter',
event = 'InsertEnter',
run = ':COQdeps',
config = function() require "plugins.coq" end
}
@ -69,13 +79,6 @@ return require('packer').startup(function(use)
end
}
use {'neovim/nvim-lspconfig', after = "coq_nvim"}
use {
'kabouzeid/nvim-lspinstall',
config = function() require "plugins.lspinstall" end,
after = 'nvim-lspconfig'
}
-- formating and editing
use {"sbdchd/neoformat", cmd = "Neoformat"}
use {
@ -95,12 +98,18 @@ return require('packer').startup(function(use)
after = "coq_nvim",
config = function() require("plugins.nvim-autopairs") end
}
use {
"rcarriga/nvim-dap-ui",
requires = {"mfussenegger/nvim-dap"},
config = function() require("plugins.dap") end
}
-- navigation
use {
'kyazdani42/nvim-tree.lua',
cmd = 'NvimTreeToggle',
requires = 'kyazdani42/nvim-web-devicons'
requires = 'kyazdani42/nvim-web-devicons',
config = function() require("plugins.nvim-tree") end
}
use {
"vimwiki/vimwiki",

36
lua/plugins/dap.lua Normal file
View File

@ -0,0 +1,36 @@
require("dapui").setup({
icons = {expanded = "", collapsed = ""},
mappings = {
-- Use a table to apply multiple mappings
expand = {"<CR>", "<2-LeftMouse>"},
open = "o",
remove = "d",
edit = "e",
repl = "r"
},
sidebar = {
-- You can change the order of elements in the sidebar
elements = {
-- Provide as ID strings or tables with "id" and "size" keys
{
id = "scopes",
size = 0.25 -- Can be float or integer > 1
}, {id = "breakpoints", size = 0.25}, {id = "stacks", size = 0.25},
{id = "watches", size = 00.25}
},
size = 40,
position = "right" -- Can be "left", "right", "top", "bottom"
},
tray = {
elements = {"repl"},
size = 10,
position = "bottom" -- Can be "left", "right", "top", "bottom"
},
floating = {
max_height = nil, -- These can be integers or a float between 0 and 1.
max_width = nil, -- Floats will be treated as percentage of your screen.
mappings = {close = {"q", "<Esc>"}}
},
windows = {indent = 1}
})

View File

@ -13,3 +13,5 @@ require'lspinstall'.post_install_hook = function ()
setup_servers() -- reload installed servers
vim.cmd("bufdo e") -- this triggers the FileType autocmd that starts the server
end
vim.cmd(':LspStart')

55
lua/plugins/nvim-tree.lua Normal file
View File

@ -0,0 +1,55 @@
-- following options are the default
require'nvim-tree'.setup {
-- disables netrw completely
disable_netrw = true,
-- hijack netrw window on startup
hijack_netrw = true,
-- open the tree when running this setup function
open_on_setup = false,
-- will not open on setup if the filetype is in this list
ignore_ft_on_setup = {},
-- closes neovim automatically when the tree is the last **WINDOW** in the view
auto_close = false,
-- opens the tree when changing/opening a new tab if the tree wasn't previously opened
open_on_tab = false,
-- hijack the cursor in the tree to put it at the start of the filename
hijack_cursor = false,
-- updates the root directory of the tree on `DirChanged` (when your run `:cd` usually)
update_cwd = false,
-- show lsp diagnostics in the signcolumn
lsp_diagnostics = false,
-- update the focused file on `BufEnter`, un-collapses the folders recursively until it finds the file
update_focused_file = {
-- enables the feature
enable = false,
-- update the root directory of the tree to the one of the folder containing the file if the file is not under the current root directory
-- only relevant when `update_focused_file.enable` is true
update_cwd = false,
-- list of buffer names / filetypes that will not update the cwd if the file isn't found under the current root directory
-- only relevant when `update_focused_file.update_cwd` is true and `update_focused_file.enable` is true
ignore_list = {}
},
-- configuration options for the system open command (`s` in the tree by default)
system_open = {
-- the command to run this, leaving nil should work in most cases
cmd = nil,
-- the command arguments as a list
args = {}
},
view = {
-- width of the window, can be either a number (columns) or a string in `%`
width = 30,
-- side of the tree, can be one of 'left' | 'right' | 'top' | 'bottom'
side = 'left',
-- if true the tree will resize itself after opening a file
auto_resize = false,
mappings = {
-- custom only false will merge the list with the default mappings
-- if true, it will only use your list to set the mappings
custom_only = false,
-- list of mappings to set on the tree manually
list = {}
}
}
}