From 97c865358f351e537f06812def31fdb545ec70b6 Mon Sep 17 00:00:00 2001 From: juan Date: Mon, 27 Sep 2021 11:56:17 +0800 Subject: [PATCH] add dap and lsp now works properly --- lua/mappings.lua | 28 ++++++++++--------- lua/pluginList.lua | 27 ++++++++++++------- lua/plugins/dap.lua | 36 +++++++++++++++++++++++++ lua/plugins/lspinstall.lua | 2 ++ lua/plugins/nvim-tree.lua | 55 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 126 insertions(+), 22 deletions(-) create mode 100644 lua/plugins/dap.lua create mode 100644 lua/plugins/nvim-tree.lua diff --git a/lua/mappings.lua b/lua/mappings.lua index 5690968..e31029c 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -23,19 +23,21 @@ vim.api.nvim_set_keymap('i', '?', '?u', {noremap = true}) -- plugin mappings -- toggle NvimTree -vim.api.nvim_set_keymap('', '', ':NvimTreeToggle', {}) +vim.api.nvim_set_keymap('', '', ':NvimTreeToggle', {silent = true}) -- toggle formatter -vim.api.nvim_set_keymap('', 'fm', ':Neoformat', {}) -vim.api.nvim_set_keymap('', '/', ':CommentToggle', {}) -vim.api.nvim_set_keymap('', 'r', ':SnipRun', {}) -vim.api.nvim_set_keymap('', 'b', ':HopWordBC', {}) -vim.api.nvim_set_keymap('', 'w', ':HopWordAC', {}) -vim.api.nvim_set_keymap('', 'k', ':HopLineStartBC', {}) -vim.api.nvim_set_keymap('', 'j', ':HopLineStartAC', {}) -vim.api.nvim_set_keymap('', 'tf', ':Telescope fd', {}) -vim.api.nvim_set_keymap('', 'tb', ':Telescope buffers', {}) -vim.api.nvim_set_keymap('', 'tq', ':Telescope quickfix', {}) +vim.api.nvim_set_keymap('', 'fm', ':Neoformat', {silent = true}) +vim.api.nvim_set_keymap('', '/', ':CommentToggle', {silent = true}) +vim.api.nvim_set_keymap('', 'r', ':SnipRun', {silent = true}) +vim.api.nvim_set_keymap('', 'b', ':HopWordBC', {silent = true}) +vim.api.nvim_set_keymap('', 'w', ':HopWordAC', {silent = true}) +vim.api.nvim_set_keymap('', 'k', ':HopLineStartBC', {silent = true}) +vim.api.nvim_set_keymap('', 'j', ':HopLineStartAC', {silent = true}) +vim.api.nvim_set_keymap('', 'tf', ':Telescope fd', {silent = true}) +vim.api.nvim_set_keymap('', 'tb', ':Telescope buffers', {silent = true}) +vim.api.nvim_set_keymap('', 'tq', ':Telescope quickfix', {silent = true}) vim.api.nvim_set_keymap('', 'tdd', - ':Telescope lsp_document_diagnostics', {}) + ':Telescope lsp_document_diagnostics', {silent = true}) vim.api.nvim_set_keymap('', 'tdw', - ':Telescope lsp_workspace_diagnostics', {}) + ':Telescope lsp_workspace_diagnostics', {silent = true}) +vim.api.nvim_set_keymap('', 'dt', ':lua require("dapui").toggle()', {silent = true}) +vim.api.nvim_set_keymap('', 'de', ':lua require("dapui").eval()', {silent = true}) diff --git a/lua/pluginList.lua b/lua/pluginList.lua index 3b06241..c3392e0 100644 --- a/lua/pluginList.lua +++ b/lua/pluginList.lua @@ -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", diff --git a/lua/plugins/dap.lua b/lua/plugins/dap.lua new file mode 100644 index 0000000..ae87640 --- /dev/null +++ b/lua/plugins/dap.lua @@ -0,0 +1,36 @@ +require("dapui").setup({ + icons = {expanded = "▾", collapsed = "▸"}, + mappings = { + -- Use a table to apply multiple mappings + expand = {"", "<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", ""}} + }, + windows = {indent = 1} +}) + diff --git a/lua/plugins/lspinstall.lua b/lua/plugins/lspinstall.lua index 6e84b10..28bd0ea 100644 --- a/lua/plugins/lspinstall.lua +++ b/lua/plugins/lspinstall.lua @@ -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') diff --git a/lua/plugins/nvim-tree.lua b/lua/plugins/nvim-tree.lua new file mode 100644 index 0000000..f72543f --- /dev/null +++ b/lua/plugins/nvim-tree.lua @@ -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 = {} + } + } +}