This commit is contained in:
Patrick Michl 2021-09-12 16:42:08 +02:00
parent ad50027cd3
commit f43691093d
7 changed files with 68 additions and 4 deletions

View File

@ -3,5 +3,7 @@ require 'plugins'
vim.cmd('colorscheme space-vim-dark') vim.cmd('colorscheme space-vim-dark')
require 'lsp' require 'lsp'
require 'debugger'
require 'term'
require 'settings' require 'settings'
require 'keys' require 'keys'

18
lua/debugger.lua Normal file
View File

@ -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;
},
}

View File

@ -21,6 +21,7 @@ local on_attach = function(client, bufnr)
buf_set_keymap('n', 'gd', ':lua vim.lsp.buf.definition()<CR>', opts) buf_set_keymap('n', 'gd', ':lua vim.lsp.buf.definition()<CR>', opts)
buf_set_keymap('n', 'ga', ':lua vim.lsp.buf.code_action()<CR>', opts) buf_set_keymap('n', 'ga', ':lua vim.lsp.buf.code_action()<CR>', opts)
buf_set_keymap('n', 'ff', ':lua vim.lsp.buf.formatting()<CR>', opts) buf_set_keymap('n', 'ff', ':lua vim.lsp.buf.formatting()<CR>', opts)
buf_set_keymap('n', 'gn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
require'completion'.on_attach(client) require'completion'.on_attach(client)
@ -48,11 +49,15 @@ local on_attach = function(client, bufnr)
) )
end end
local servers = require'lspinstall'.installed_servers() local servers = require'lspinstall'.installed_servers()
for _, lsp in ipairs(servers) do for _, lsp in ipairs(servers) do
nvim_lsp[lsp].setup{ local config = {
on_attach = on_attach, on_attach = on_attach,
flags = {debounce_text_changes = 150} flags = {debounce_text_changes = 150}
} }
if lsp == "lua" then
config.settings = require'lsp.lua'
end
nvim_lsp[lsp].setup(config)
end end

22
lua/lsp/lua.lua Normal file
View File

@ -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

View File

@ -1,4 +1,3 @@
local vim = vim -- Workaround to get rid of warnings
vim.cmd([[autocmd BufWritePost plugins.lua source <afile> | PackerCompile]]) vim.cmd([[autocmd BufWritePost plugins.lua source <afile> | PackerCompile]])
return require('packer').startup({function() return require('packer').startup({function()
@ -24,6 +23,7 @@ return require('packer').startup({function()
use 'xolox/vim-misc' use 'xolox/vim-misc'
use 'jremmen/vim-ripgrep' use 'jremmen/vim-ripgrep'
use 'airblade/vim-gitgutter' use 'airblade/vim-gitgutter'
use 'akinsho/toggleterm.nvim'
-- LSP Setup -- LSP Setup
use 'neovim/nvim-lspconfig' use 'neovim/nvim-lspconfig'
use 'kabouzeid/nvim-lspinstall' use 'kabouzeid/nvim-lspinstall'
@ -31,6 +31,8 @@ return require('packer').startup({function()
use 'nvim-lua/completion-nvim' use 'nvim-lua/completion-nvim'
use 'nvim-lua/popup.nvim' use 'nvim-lua/popup.nvim'
use 'nvim-lua/plenary.nvim' use 'nvim-lua/plenary.nvim'
-- Debugger --
use 'mfussenegger/nvim-dap'
end, end,
config = { config = {
display = { display = {

View File

@ -24,4 +24,4 @@ bo.shiftwidth = 2
bo.expandtab = true bo.expandtab = true
wo.relativenumber = true wo.relativenumber = true
o.hidden = true

15
lua/term.lua Normal file
View File

@ -0,0 +1,15 @@
require("toggleterm").setup{
-- size can be a number or function which is passed the current terminal
size = 20,
open_mapping = [[<c-\>]],
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
}