Skip to content

Commit

Permalink
adds lsp to nvim
Browse files Browse the repository at this point in the history
still no ff
  • Loading branch information
jvscholz authored Jun 2, 2024
1 parent 4c8e6dd commit 57ed39f
Show file tree
Hide file tree
Showing 9 changed files with 240 additions and 0 deletions.
35 changes: 35 additions & 0 deletions nvim/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
vim.g.mapleader = ' '

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup("j.plugins")

vim.o.background = "dark" -- or "light" for light mode
vim.cmd([[colorscheme gruvbox]])
vim.opt.clipboard = 'unnamedplus'
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.expandtab = true
vim.opt.shiftwidth = 2
vim.opt.tabstop = 2
vim.opt.expandtab = true
vim.opt.shiftwidth = 2
vim.opt.tabstop = 2

-- nvim-tree bindings
vim.api.nvim_set_keymap('n', '<leader>e', ':NvimTreeToggle<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<C-h>', '<C-w>h', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<C-j>', '<C-w>j', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<C-k>', '<C-w>k', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<C-l>', '<C-w>l', { noremap = true, silent = true })
6 changes: 6 additions & 0 deletions nvim/lua/j/plugins/alpha.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
return {
'goolord/alpha-nvim',
config = function ()
require'alpha'.setup(require'alpha.themes.dashboard'.config)
end,
}
7 changes: 7 additions & 0 deletions nvim/lua/j/plugins/autopairs.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
return {
'windwp/nvim-autopairs',
event = "InsertEnter",
config = true
-- use opts = {} for passing setup options
-- this is equalent to setup({}) function
}
10 changes: 10 additions & 0 deletions nvim/lua/j/plugins/comment.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
return {
'numToStr/Comment.nvim',
opts = {
-- add any options here
},
lazy = false,
config = function()
require('Comment').setup()
end
}
4 changes: 4 additions & 0 deletions nvim/lua/j/plugins/gruvbox.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
return {
"ellisonleao/gruvbox.nvim", priority = 1000 , config = true
}

94 changes: 94 additions & 0 deletions nvim/lua/j/plugins/lsp-zero.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
return {
{
'VonHeikemen/lsp-zero.nvim',
branch = 'v3.x',
lazy = true,
config = false,
init = function()
-- Disable automatic setup, we are doing it manually
vim.g.lsp_zero_extend_cmp = 0
vim.g.lsp_zero_extend_lspconfig = 0
end,
},
{
'williamboman/mason.nvim',
lazy = false,
config = true,
},

-- Autocompletion
{
'hrsh7th/nvim-cmp',
event = 'InsertEnter',
dependencies = {
{'L3MON4D3/LuaSnip'},
},
config = function()
-- Here is where you configure the autocompletion settings.
local lsp_zero = require('lsp-zero')
lsp_zero.extend_cmp()

-- And you can configure cmp even more, if you want to.
local cmp = require('cmp')
local cmp_action = lsp_zero.cmp_action()

cmp.setup({
formatting = lsp_zero.cmp_format({details = true}),
mapping = cmp.mapping.preset.insert({
['<C-Space>'] = cmp.mapping.complete(),
['<C-u>'] = cmp.mapping.scroll_docs(-4),
['<C-d>'] = cmp.mapping.scroll_docs(4),
['<C-f>'] = cmp_action.luasnip_jump_forward(),
['<C-b>'] = cmp_action.luasnip_jump_backward(),
}),
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
})
end
},

-- LSP
{
'neovim/nvim-lspconfig',
cmd = {'LspInfo', 'LspInstall', 'LspStart'},
event = {'BufReadPre', 'BufNewFile'},
dependencies = {
{'hrsh7th/cmp-nvim-lsp'},
{'williamboman/mason-lspconfig.nvim'},
},
config = function()
-- This is where all the LSP shenanigans will live
local lsp_zero = require('lsp-zero')
lsp_zero.extend_lspconfig()

--- if you want to know more about lsp-zero and mason.nvim
--- read this: https://github.com/VonHeikemen/lsp-zero.nvim/blob/v3.x/doc/md/guides/integrate-with-mason-nvim.md
lsp_zero.on_attach(function(client, bufnr)
-- see :help lsp-zero-keybindings
-- to learn the available actions
lsp_zero.default_keymaps({buffer = bufnr})
end)

require('mason-lspconfig').setup({
ensure_installed = {},
handlers = {
-- this first function is the "default handler"
-- it applies to every language server without a "custom handler"
function(server_name)
require('lspconfig')[server_name].setup({})
end,

-- this is the "custom handler" for `lua_ls`
lua_ls = function()
-- (Optional) Configure lua language server for neovim
local lua_opts = lsp_zero.nvim_lua_ls()
require('lspconfig').lua_ls.setup(lua_opts)
end,
}
})
end
}
}
10 changes: 10 additions & 0 deletions nvim/lua/j/plugins/lualine.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
return {
'nvim-lualine/lualine.nvim',
dependencies = { 'nvim-tree/nvim-web-devicons' },
config = function()
require('lualine').setup {
options = { theme = 'gruvbox_dark' }
}
end
}

60 changes: 60 additions & 0 deletions nvim/lua/j/plugins/nvim-tree.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
return {
"nvim-tree/nvim-tree.lua",
dependencies = {
"nvim-tree/nvim-web-devicons"
},
config = function()
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1

-- optionally enable 24-bit colour
vim.opt.termguicolors = true

-- empty setup using defaults
require("nvim-tree").setup()

-- OR setup with some options
require("nvim-tree").setup({
sort = {
sorter = "case_sensitive",
},
view = {
width = 30,
},
renderer = {
group_empty = true,
},
filters = {
dotfiles = true,
},
})

require("nvim-tree").setup({
renderer = {
icons = {
show = {
git = true,
file = false,
folder = false,
folder_arrow = true,
},
glyphs = {
folder = {
arrow_closed = "",
arrow_open = "",
},
git = {
unstaged = "",
staged = "",
unmerged = "",
renamed = "",
untracked = "",
deleted = "",
ignored = "",
},
},
},
},
})
end
}
14 changes: 14 additions & 0 deletions nvim/lua/j/plugins/nvim-treesitter.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
return {
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
config = function ()
local configs = require("nvim-treesitter.configs")

configs.setup({
ensure_installed = { "c", "lua", "vim", "vimdoc", "rust", "go", "cpp", "javascript", "html" },
sync_install = false,
highlight = { enable = true },
indent = { enable = true },
})
end
}

0 comments on commit 57ed39f

Please sign in to comment.