Split up neonvim configuration into lua files rather than lua heredoc
This commit is contained in:
parent
673500eea6
commit
8de18fd135
@ -5,65 +5,9 @@ source ~/.vimrc
|
|||||||
lua <<EOF
|
lua <<EOF
|
||||||
vim.g.mapleader = ','
|
vim.g.mapleader = ','
|
||||||
|
|
||||||
-- print('Hello from lua')
|
require('user.lspconfig')
|
||||||
require'lspconfig'.pylsp.setup{}
|
require('user.indentblanklines')
|
||||||
require'lspconfig'.solargraph.setup{}
|
|
||||||
|
|
||||||
-- Configure the 'indent-blankline' plugin
|
|
||||||
-- Look at configuring this for rainbow blocks at some point
|
|
||||||
require('ibl').setup{
|
|
||||||
enabled = false,
|
|
||||||
indent = {
|
|
||||||
char = '|'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Setup LSP bindings
|
|
||||||
vim.api.nvim_create_autocmd('LspAttach', {
|
|
||||||
desc = 'LSP actions',
|
|
||||||
callback = function()
|
|
||||||
local bufmap = function(mode, lhs, rhs)
|
|
||||||
local opts = {buffer = true}
|
|
||||||
vim.keymap.set(mode, lhs, rhs, opts)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Displays hover information about the symbol under the cursor
|
|
||||||
bufmap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>')
|
|
||||||
|
|
||||||
-- Jump to the definition
|
|
||||||
bufmap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>')
|
|
||||||
|
|
||||||
-- Jump to declaration
|
|
||||||
bufmap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>')
|
|
||||||
|
|
||||||
-- Lists all the implementations for the symbol under the cursor
|
|
||||||
bufmap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>')
|
|
||||||
|
|
||||||
-- Jumps to the definition of the type symbol
|
|
||||||
bufmap('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>')
|
|
||||||
|
|
||||||
-- Lists all the references
|
|
||||||
bufmap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>')
|
|
||||||
|
|
||||||
-- Displays a function's signature information
|
|
||||||
bufmap('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<cr>')
|
|
||||||
|
|
||||||
-- Renames all references to the symbol under the cursor
|
|
||||||
bufmap('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<cr>')
|
|
||||||
|
|
||||||
-- Selects a code action available at the current cursor position
|
|
||||||
bufmap('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>')
|
|
||||||
|
|
||||||
-- Show diagnostics in a floating window
|
|
||||||
bufmap('n', 'gl', '<cmd>lua vim.diagnostic.open_float()<cr>')
|
|
||||||
|
|
||||||
-- Move to the previous diagnostic
|
|
||||||
bufmap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<cr>')
|
|
||||||
|
|
||||||
-- Move to the next diagnostic
|
|
||||||
bufmap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<cr>')
|
|
||||||
end
|
|
||||||
})
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
nnoremap <leader>ib <cmd>IBLToggle<cr>
|
nnoremap <leader>ib <cmd>IBLToggle<cr>
|
||||||
|
|||||||
8
vim/.config/nvim/lua/user/indentblanklines.lua
Normal file
8
vim/.config/nvim/lua/user/indentblanklines.lua
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
-- Configure the 'indent-blankline' plugin
|
||||||
|
-- Look at configuring this for rainbow blocks at some point
|
||||||
|
require('ibl').setup{
|
||||||
|
enabled = false,
|
||||||
|
indent = {
|
||||||
|
char = '|'
|
||||||
|
}
|
||||||
|
}
|
||||||
85
vim/.config/nvim/lua/user/lspconfig.lua
Normal file
85
vim/.config/nvim/lua/user/lspconfig.lua
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
print('User LSP Configuration loaded')
|
||||||
|
local lsp = require('lspconfig')
|
||||||
|
|
||||||
|
-- Configure LuaLS for lua
|
||||||
|
lsp.lua_ls.setup{
|
||||||
|
on_init = function(client)
|
||||||
|
local path = client.workspace_folders[1].name
|
||||||
|
if not vim.loop.fs_stat(path..'/.luarc.json') and not vim.loop.fs_stat(path..'/.luarc.jsonc') then
|
||||||
|
client.config.settings = vim.tbl_deep_extend('force', client.config.settings, {
|
||||||
|
Lua = {
|
||||||
|
runtime = {
|
||||||
|
-- Tell the language server which version of Lua you're using
|
||||||
|
-- (most likely LuaJIT in the case of Neovim)
|
||||||
|
version = 'LuaJIT'
|
||||||
|
},
|
||||||
|
-- Make the server aware of Neovim runtime files
|
||||||
|
workspace = {
|
||||||
|
checkThirdParty = false,
|
||||||
|
library = {
|
||||||
|
vim.env.VIMRUNTIME
|
||||||
|
-- "${3rd}/luv/library"
|
||||||
|
-- "${3rd}/busted/library",
|
||||||
|
}
|
||||||
|
-- or pull in all of 'runtimepath'. NOTE: this is a lot slower
|
||||||
|
-- library = vim.api.nvim_get_runtime_file("", true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
client.notify("workspace/didChangeConfiguration", { settings = client.config.settings })
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
lsp.pylsp.setup{}
|
||||||
|
lsp.solargraph.setup{}
|
||||||
|
|
||||||
|
|
||||||
|
-- Setup LSP bindings
|
||||||
|
vim.api.nvim_create_autocmd('LspAttach', {
|
||||||
|
desc = 'LSP actions',
|
||||||
|
callback = function()
|
||||||
|
local bufmap = function(mode, lhs, rhs)
|
||||||
|
local opts = {buffer = true}
|
||||||
|
vim.keymap.set(mode, lhs, rhs, opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Displays hover information about the symbol under the cursor
|
||||||
|
bufmap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>')
|
||||||
|
|
||||||
|
-- Jump to the definition
|
||||||
|
bufmap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>')
|
||||||
|
|
||||||
|
-- Jump to declaration
|
||||||
|
bufmap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>')
|
||||||
|
|
||||||
|
-- Lists all the implementations for the symbol under the cursor
|
||||||
|
bufmap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>')
|
||||||
|
|
||||||
|
-- Jumps to the definition of the type symbol
|
||||||
|
bufmap('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>')
|
||||||
|
|
||||||
|
-- Lists all the references
|
||||||
|
bufmap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>')
|
||||||
|
|
||||||
|
-- Displays a function's signature information
|
||||||
|
bufmap('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<cr>')
|
||||||
|
|
||||||
|
-- Renames all references to the symbol under the cursor
|
||||||
|
bufmap('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<cr>')
|
||||||
|
|
||||||
|
-- Selects a code action available at the current cursor position
|
||||||
|
bufmap('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>')
|
||||||
|
|
||||||
|
-- Show diagnostics in a floating window
|
||||||
|
bufmap('n', 'gl', '<cmd>lua vim.diagnostic.open_float()<cr>')
|
||||||
|
|
||||||
|
-- Move to the previous diagnostic
|
||||||
|
bufmap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<cr>')
|
||||||
|
|
||||||
|
-- Move to the next diagnostic
|
||||||
|
bufmap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<cr>')
|
||||||
|
end
|
||||||
|
})
|
||||||
Loading…
x
Reference in New Issue
Block a user