Compare commits

..

17 Commits

15 changed files with 337 additions and 23 deletions

View File

@ -0,0 +1,2 @@
/assign_reviewer @patrick.michl

View File

@ -1,7 +1,19 @@
require 'plugins'
vim.cmd('colorscheme space-vim-dark')
vim.g.loaded = 1
vim.g.loaded_netrwPlugin = 1
require('onedark').setup {
style = 'warmer'
}
require('onedark').load()
vim.cmd('set background=dark')
require 'lsp'
require 'completion'
require 'treesitter'
require 'term'
require 'settings'
require 'keys'
require("symbols-outline").setup()
require"fidget".setup{}

50
lua/completion.lua Normal file
View File

@ -0,0 +1,50 @@
local luasnip = require 'luasnip'
local cmp = require 'cmp'
cmp.setup {
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
window = {
documentation = true
},
mapping = cmp.mapping.preset.insert({
['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-n>'] = cmp.mapping.select_next_item(),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
},
['<Tab>'] = function(fallback)
if vim.fn.pumvisible() == 1 then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<C-n>', true, true, true), 'n')
elseif luasnip.expand_or_jumpable() then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-expand-or-jump', true, true, true), '')
else
fallback()
end
end,
['<S-Tab>'] = function(fallback)
if vim.fn.pumvisible() == 1 then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<C-p>', true, true, true), 'n')
elseif luasnip.jumpable(-1) then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-jump-prev', true, true, true), '')
else
fallback()
end
end,
}),
sources = {
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'buffer' },
{ name = 'path' },
{ name = 'latex_symbols' },
},
}

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

@ -1,11 +1,33 @@
local key = vim.api.nvim_set_keymap
local u = require('utils')
vim.cmd([[autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif]])
vim.cmd([[autocmd BufNewFile,BufRead *.md setlocal filetype=notes]])
vim.cmd([[autocmd CursorHold * lua vim.diagnostic.open_float({focusable = false})]])
key('n', ';', ':Files<CR>', {})
key('', '<C-n>', ':NERDTreeToggle<CR>', {})
key('n', ';', ':Telescope find_files<CR>', {})
key('n', '<C-n>', ':NvimTreeToggle<CR>', {})
key('n', 'gh', '/<c-r>=expand("<cword>")<CR><CR>N', {})
key('i', '<TAB>', 'pumvisible() ? "<C-n>" : "<Tab>"', {expr = true, silent = true})
key('i', '<S-TAB>', 'pumvisible() ? "<C-p>" : "<S-Tab>"', {expr = true, silent = true})
key('i', '<TAB>', 'pumvisible() ? "<C-n>" : "<Tab>"', { expr = true, silent = true })
key('i', '<S-TAB>', 'pumvisible() ? "<C-p>" : "<S-Tab>"', { expr = true, silent = true })
key('n', '<leader>g', ':lua require"telescope.builtin".live_grep{}<CR>', {})
key('v', '<leader>c', ':w !xclip -sel c<CR><CR>', { silent = true })
-- Highlight on yank
vim.api.nvim_exec(
[[
augroup YankHighlight
autocmd!
autocmd TextYankPost * silent! lua vim.highlight.on_yank()
augroup end
]] ,
false
)
vim.api.nvim_create_autocmd("BufEnter", {
nested = true,
callback = function()
if #vim.api.nvim_list_wins() == 1 and vim.api.nvim_buf_get_name(0):match("NvimTree_") ~= nil then
vim.cmd 'quit'
end
end
})

View File

@ -1,4 +1,3 @@
require'lspinstall'.setup()
local u = require('utils')
local nvim_lsp = require'lspconfig'
@ -21,8 +20,9 @@ local on_attach = function(client, bufnr)
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', '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)
-- Set highlight colors
local highlights = {
@ -46,13 +46,32 @@ local on_attach = function(client, bufnr)
underline = true
}
)
require "lsp_signature".on_attach({doc_lines = 0})
end
local servers = require'lspinstall'.installed_servers()
for _, lsp in ipairs(servers) do
nvim_lsp[lsp].setup{
-- nvim-cmp supports additional completion capabilities
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
local servers = require'nvim-lsp-installer'
servers.on_server_ready(function(server)
local config = {
on_attach = on_attach,
capabilities = capabilities,
flags = {debounce_text_changes = 150}
}
end
if server.name == "sumneko_lua" then
config.settings = require'lsp.lua'
end
if server.name == "rust_analyzer" then
config.settings = require'lsp.rust'
end
server:setup(config)
end)
-- Set completeopt to have a better completion experience
vim.o.completeopt = 'menuone,noselect'

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

19
lua/lsp/rust.lua Normal file
View File

@ -0,0 +1,19 @@
local M = {
['rust-analyzer'] = {
assist = {
importGranularity = "module",
importPrefix = "by_self",
},
cargo = {
loadOutDirsFromCheck = true
},
procMacro = {
enable = true
},
checkOnSave = {
command = "clippy"
},
}
}
return M

View File

@ -1,19 +1,52 @@
local vim = vim -- Workaround to get rid of warnings
local ensure_packer = function()
local fn = vim.fn
local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
if fn.empty(fn.glob(install_path)) > 0 then
fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
vim.cmd [[packadd packer.nvim]]
return true
end
return false
end
local packer_bootstrap = ensure_packer()
vim.cmd([[autocmd BufWritePost plugins.lua source <afile> | PackerCompile]])
return require('packer').startup({function()
local use = use
-- Packer can manage itself
use 'wbthomason/packer.nvim'
-- Theme
use 'navarasu/onedark.nvim'
-- use 'liuchengxu/space-vim-dark'
use 'vim-airline/vim-airline'
use 'scrooloose/nerdtree'
use 'Xuyuanp/nerdtree-git-plugin'
use 'liuchengxu/space-vim-dark'
use {
'nvim-lualine/lualine.nvim',
requires = {'kyazdani42/nvim-web-devicons', opt = true},
config = function() require('plugins/lualine') end
}
use {
"folke/todo-comments.nvim",
requires = "nvim-lua/plenary.nvim",
config = function() require("todo-comments").setup()end
}
use {
"folke/which-key.nvim",
config = function() require("which-key").setup() end
}
use {
'jremmen/vim-ripgrep',
op = true,
cmd = { 'Rg' }
}
use {
'tpope/vim-dispatch',
opt = true,
cmd = { 'Dispatch', 'Dispatch!' }
}
use 'tpope/vim-fugitive'
use 'tpope/vim-commentary'
use { 'tpope/vim-dispatch', opt = true, cmd = { 'Dispatch', 'Dispatch!' } }
use 'junegunn/fzf.vim'
use 'sheerun/vim-polyglot'
use 'honza/vim-snippets'
use 'szw/vim-tags'
@ -22,15 +55,50 @@ return require('packer').startup({function()
use 'tpope/vim-haml'
use 'xolox/vim-notes'
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'
use 'williamboman/nvim-lsp-installer'
use 'nvim-lua/lsp_extensions.nvim'
use 'ray-x/lsp_signature.nvim'
use 'nvim-lua/completion-nvim'
use 'nvim-lua/popup.nvim'
use {
'nvim-telescope/telescope.nvim',
requires = { {'nvim-lua/plenary.nvim'} }
}
use 'nvim-lua/plenary.nvim'
use 'L3MON4D3/LuaSnip' -- Snippets plugin
use 'hrsh7th/nvim-cmp' -- Autocompletion plugin
use 'hrsh7th/cmp-nvim-lsp'
use 'saadparwaiz1/cmp_luasnip'
use "hrsh7th/cmp-buffer"
use "hrsh7th/cmp-path"
use 'kdheepak/cmp-latex-symbols'
use 'nvim-treesitter/nvim-treesitter'
use 'simrat39/symbols-outline.nvim'
use 'j-hui/fidget.nvim'
use 'kyazdani42/nvim-web-devicons'
use 'stevearc/dressing.nvim'
use {
'kyazdani42/nvim-tree.lua',
cmd = {
'NvimTreeOpen',
'NvimTreeFocus',
'NvimTreeToggle',
},
config = function() require'plugins/nvim-tree' end
}
use 'justinmk/vim-sneak'
if packer_bootstrap then
require('packer').sync()
end
end,
config = {
display = {

14
lua/plugins/lualine.lua Normal file
View File

@ -0,0 +1,14 @@
-- Inserts a component in lualine_c at left section
local config = {}
local function ins_left(component)
table.insert(config.sections.lualine_c, component)
end
-- Inserts a component in lualine_x ot right section
local function ins_right(component)
table.insert(config.sections.lualine_x, component)
end
local config = require('lualine').get_config()
config.options.theme = 'onedark'
require('lualine').setup(config)

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

@ -0,0 +1,33 @@
local tree_cb = require('nvim-tree.config').nvim_tree_callback
require("nvim-tree").setup {
auto_close = true,
view = {
width = "15%",
side = "left",
mappings = {
custom_only = true,
list = {
{ key = {"<CR>", "<2-LeftMouse>"}, cb = tree_cb("edit") },
{ key = "vs", cb = tree_cb("vsplit") },
{ key = "s", cb = tree_cb("split") },
{ key = "t", cb = tree_cb("tabnew") },
{ key = "<Tab>", cb = tree_cb("preview") },
{ key = "K", cb = tree_cb("first_sibling") },
{ key = "J", cb = tree_cb("last_sibling") },
{ key = "R", cb = tree_cb("refresh") },
{ key = "ma", cb = tree_cb("create") },
{ key = "md", cb = tree_cb("remove") },
{ key = "mm", cb = tree_cb("rename") },
{ key = "<C-r>", cb = tree_cb("full_rename") },
{ key = "mc", cb = ':lua require"nvim-tree".on_keypress("copy");require"nvim-tree".on_keypress("paste")<CR>' },
{ key = "?", cb = tree_cb("toggle_help") },
}
}
}
}
-- Hide statusline in nvim-tree buffer/tabs.
-- vim.cmd('au BufEnter,BufWinEnter,WinEnter,CmdwinEnter * if bufname("%") == "NvimTree" | set laststatus=0 | else | set laststatus=2 | endif')

View File

@ -0,0 +1,2 @@
require('telescope').load_extension('fzf')

View File

@ -7,6 +7,7 @@ cmd('syntax on')
cmd('set number')
cmd('set completeopt=menuone,noinsert,noselect')
cmd('set shortmess+=c')
cmd("autocmd CursorHold,CursorHoldI *.rs :lua require'lsp_extensions'.inlay_hints{ only_current_line = true }")
o.startofline = true
wo.cursorline = true
@ -24,4 +25,4 @@ bo.shiftwidth = 2
bo.expandtab = 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
}

17
lua/treesitter.lua Normal file
View File

@ -0,0 +1,17 @@
require('nvim-treesitter.configs').setup {
highlight = {
enable = true, -- false will disable the whole extension
},
incremental_selection = {
enable = false,
keymaps = {
init_selection = 'gnn',
node_incremental = 'grn',
scope_incremental = 'grc',
node_decremental = 'grm',
},
},
indent = {
enable = true,
}
}