From f43691093d29d8480e5270dcb12a96e69adc773b Mon Sep 17 00:00:00 2001 From: Patrick Michl Date: Sun, 12 Sep 2021 16:42:08 +0200 Subject: [PATCH] changes --- init.lua | 2 ++ lua/debugger.lua | 18 ++++++++++++++++++ lua/lsp.lua | 9 +++++++-- lua/lsp/lua.lua | 22 ++++++++++++++++++++++ lua/plugins.lua | 4 +++- lua/settings.lua | 2 +- lua/term.lua | 15 +++++++++++++++ 7 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 lua/debugger.lua create mode 100644 lua/lsp/lua.lua create mode 100644 lua/term.lua diff --git a/init.lua b/init.lua index 2ed6ea0..30854a0 100644 --- a/init.lua +++ b/init.lua @@ -3,5 +3,7 @@ require 'plugins' vim.cmd('colorscheme space-vim-dark') require 'lsp' +require 'debugger' +require 'term' require 'settings' require 'keys' diff --git a/lua/debugger.lua b/lua/debugger.lua new file mode 100644 index 0000000..623b3f5 --- /dev/null +++ b/lua/debugger.lua @@ -0,0 +1,18 @@ +local dap = require('dap') + +dap.adapters.ruby = { + type = 'executable'; + command = 'bundle'; + args = {'exec', 'readapt', 'stdio'}; +} + +dap.configurations.ruby = { + { + type = 'ruby'; + request = 'launch'; + name = 'Rails'; + program = 'bundle'; + programArgs = {'exec', 'rails', 's'}; + useBundler = true; + }, +} diff --git a/lua/lsp.lua b/lua/lsp.lua index 8db2b81..a542740 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -21,6 +21,7 @@ local on_attach = function(client, bufnr) buf_set_keymap('n', 'gd', ':lua vim.lsp.buf.definition()', opts) buf_set_keymap('n', 'ga', ':lua vim.lsp.buf.code_action()', opts) buf_set_keymap('n', 'ff', ':lua vim.lsp.buf.formatting()', opts) + buf_set_keymap('n', 'gn', 'lua vim.lsp.buf.rename()', opts) require'completion'.on_attach(client) @@ -48,11 +49,15 @@ local on_attach = function(client, bufnr) ) end + local servers = require'lspinstall'.installed_servers() for _, lsp in ipairs(servers) do - nvim_lsp[lsp].setup{ + local config = { on_attach = on_attach, flags = {debounce_text_changes = 150} } + if lsp == "lua" then + config.settings = require'lsp.lua' + end + nvim_lsp[lsp].setup(config) end - diff --git a/lua/lsp/lua.lua b/lua/lsp/lua.lua new file mode 100644 index 0000000..07fcd9d --- /dev/null +++ b/lua/lsp/lua.lua @@ -0,0 +1,22 @@ +local M = { + Lua = { + runtime = { + -- LuaJIT in the case of Neovim + version = 'LuaJIT', + path = vim.split(package.path, ';'), + }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = {'vim'}, + }, + workspace = { + -- Make the server aware of Neovim runtime files + library = { + [vim.fn.expand('$VIMRUNTIME/lua')] = true, + [vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true, + }, + }, + } +} + +return M diff --git a/lua/plugins.lua b/lua/plugins.lua index e8d9e0a..af18b4a 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -1,4 +1,3 @@ -local vim = vim -- Workaround to get rid of warnings vim.cmd([[autocmd BufWritePost plugins.lua source | PackerCompile]]) return require('packer').startup({function() @@ -24,6 +23,7 @@ return require('packer').startup({function() use 'xolox/vim-misc' use 'jremmen/vim-ripgrep' use 'airblade/vim-gitgutter' + use 'akinsho/toggleterm.nvim' -- LSP Setup use 'neovim/nvim-lspconfig' use 'kabouzeid/nvim-lspinstall' @@ -31,6 +31,8 @@ return require('packer').startup({function() use 'nvim-lua/completion-nvim' use 'nvim-lua/popup.nvim' use 'nvim-lua/plenary.nvim' + -- Debugger -- + use 'mfussenegger/nvim-dap' end, config = { display = { diff --git a/lua/settings.lua b/lua/settings.lua index 602ba19..8fc5c69 100644 --- a/lua/settings.lua +++ b/lua/settings.lua @@ -24,4 +24,4 @@ bo.shiftwidth = 2 bo.expandtab = true wo.relativenumber = true - +o.hidden = true diff --git a/lua/term.lua b/lua/term.lua new file mode 100644 index 0000000..3d01d18 --- /dev/null +++ b/lua/term.lua @@ -0,0 +1,15 @@ +require("toggleterm").setup{ + -- size can be a number or function which is passed the current terminal + size = 20, + open_mapping = [[]], + hide_numbers = true, -- hide the number column in toggleterm buffers + shade_filetypes = {}, + shade_terminals = true, + shading_factor = 1, -- the degree by which to darken to terminal colour, default: 1 for dark backgrounds, 3 for light + start_in_insert = true, + insert_mappings = true, -- whether or not the open mapping applies in insert mode + persist_size = true, + direction = 'horizontal', + close_on_exit = false, -- close the terminal window when the process exits + shell = vim.o.shell, -- change the default shell +}