neovim goodness

This commit is contained in:
Daniel Lundin 2022-03-04 12:11:26 +01:00
parent 0e80fa3b8f
commit d2c2041fa4
6 changed files with 43 additions and 64 deletions

2
.config/nvim/init.lua Normal file
View file

@ -0,0 +1,2 @@
require("plugins")
require("settings")

View file

@ -1,35 +0,0 @@
lua require("init")
set title
set titlestring=%F%m\ %r\ %y
function s:recompile_plugins()
luafile %
PackerCompile
endfunction
"" Autocommands
augroup recompile_plugins
autocmd!
autocmd BufWritePost plugins.lua call <SID>recompile_plugins()
augroup END
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
autocmd BufRead,BufNewFile *.hcl set filetype=terraform
autocmd BufRead,BufNewFile *.tf set filetype=terraform
"" Temporary hacks
" Show syntax highlight group in the status bar
map ,H :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<'
\ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<"
\ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>
function! SynGroup()
let l:s = synID(line('.'), col('.'), 1)
echo synIDattr(l:s, 'name') . ' -> ' . synIDattr(synIDtrans(l:s), 'name')
endfun
map ,J :call SynGroup()<CR>
map ,L :luafile %<CR>

View file

@ -2,6 +2,10 @@ local lspconfig = require("lspconfig")
-- local configs = require("lspconfig.configs")
local util = require("lspconfig.util")
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
vim.lsp.handlers["textDocument/publishDiagnostics"] =
vim.lsp.with(
vim.lsp.diagnostic.on_publish_diagnostics,
@ -81,11 +85,12 @@ local yaml_is_k8s = function(bufnr)
end
lspconfig.cssls.setup {
cmd = { "css-languageserver", "--stdio" },
filetypes = { "css" },
settings = {}
cmd = { "vscode-css-languageserver", "--stdio" },
capabilities = capabilities,
}
lspconfig.cssmodules_ls.setup{}
lspconfig.html.setup {
cmd = { "vscode-html-languageserver", "--stdio" },
filetypes = { "html" },

View file

@ -6,10 +6,8 @@ return require('packer').startup(function()
use 'ray-x/lsp_signature.nvim'
use 'jose-elias-alvarez/nvim-lsp-ts-utils'
use 'rafamadriz/friendly-snippets'
use 'mfussenegger/nvim-dap'
use {'ray-x/guihua.lua', run = 'cd lua/fzy && make'}
use { "rcarriga/nvim-dap-ui", requires = {"mfussenegger/nvim-dap"} }
use {'ray-x/guihua.lua', run = 'cd lua/fzy && make'}
use {
'theHamsta/nvim-dap-virtual-text',
@ -20,6 +18,14 @@ return require('packer').startup(function()
end
}
use({
"jose-elias-alvarez/null-ls.nvim",
requires = { "nvim-lua/plenary.nvim" },
config = function()
require("plugins/null-ls")
end,
})
use {
'b3nj5m1n/kommentary',
config = function()
@ -234,9 +240,8 @@ return require('packer').startup(function()
map('n', 'g?', '<cmd>lua require("telescope.builtin").lsp_workspace_symbols()<CR>')
map('n', 'ge', '<cmd>lua require("telescope.builtin").lsp_document_diagnostics()<CR>')
map('n', 'Db', '<cmd>lua require("telescope").extensions.dap.list_breakpoints()<CR>')
map('n', 'Dc', '<cmd>lua require("telescope").extensions.dap.commands()<CR>')
map('n', 'Dcc', '<cmd>lua require("telescope").extensions.dap.commands()<CR>')
map('n', 'Df', '<cmd>lua require("telescope").extensions.dap.frames()<CR>')
map('n', 'DD', '<cmd>:GoBreakToggle<CR>')
map('n', 'Dv', '<cmd>lua require("telescope").extensions.dap.variables()<CR>')
end
}
@ -256,25 +261,13 @@ return require('packer').startup(function()
end
}
use {
'mattn/efm-langserver',
config = function()
require "lspconfig".efm.setup {
init_options = {documentFormatting = true},
settings = {
}
}
end
}
use {
"ray-x/go.nvim",
config = function()
require('go').setup({
comment_placeholder = '',
icons = {breakpoint = '🧘', currentpos = '🏃'},
dap_debug_gui = true
dap_debug_gui = false
})
vim.cmd("autocmd FileType go nmap <Leader>c :lua require('go.comment').gen()<cr>")
vim.cmd("autocmd BufWritePre *.go :silent! lua require('go.format').gofmt()")
@ -296,6 +289,18 @@ return require('packer').startup(function()
config = function() require("plugins/marks") end,
}
-- dap
use {
'mfussenegger/nvim-dap',
config = function() require("plugins/dap") end,
}
-- go
use {
"leoluz/nvim-dap-go",
config = function() require("plugins/nvim-dap-go") end,
}
-- zenbones
use {
"mcchrish/zenbones.nvim",

View file

@ -15,7 +15,7 @@ local specs = lush.parse(function()
CursorLine { bg = "#f5f5f0" },
CursorLineNr { fg = "#BCAAA4", bg="#f5f5f0" },
MsgArea { fg = "#A1887F", bg="#f1f1f1" },
String { fg = "#33691E", gui = "italic" },
String { fg = "#2E7D32", gui = "italic" },
Comment { fg = "#114499", gui = "bold,italic" },
LineNr { fg = "#CFD8DC", gui = "bold,italic" },
Indent1 { fg = "#FFEBEE", gui = "italic" },

View file

@ -12,6 +12,8 @@ vim.o.updatetime = 100
vim.o.autochdir = true
vim.o.backupdir = "/home/dln/.local/share/nvim/backup/"
vim.o.backup = true
vim.g.netrw_dirhistmax = 0
vim.o.clipboard = "unnamedplus"
--- Indent
vim.o.autoindent = true
@ -44,7 +46,7 @@ vim.o.completeopt = 'menuone,noinsert,noselect'
--- Appearance
vim.o.background = 'light'
vim.o.scrolloff = 8
vim.o.scrolloff = 5
vim.o.showmode = false
vim.o.sidescrolloff = 5
vim.o.termguicolors = true
@ -54,6 +56,10 @@ vim.wo.signcolumn = "yes"
vim.o.laststatus = 0
vim.o.statusline = ""
vim.o.fillchars = "stl:═,stlnc:═"
vim.o.title = true
vim.o.titlestring = "%F%m %r %y"
vim.wo.foldmethod = "expr"
vim.wo.foldexpr = "nvim_treesitter#foldexpr()"
--- Key mappings
local map = require("dln.utils").map
@ -62,10 +68,11 @@ map('n', 'H', '^')
map('n', 'L', '$')
map('i', '', '<C-w>')
map('n', ',L', ':luafile %<CR>') -- Reload lua file
--- Plugins
vim.g.netrw_dirhistmax = 0
require('plugins')
local border = {
{"🭽", "FloatBorder"},
@ -80,8 +87,3 @@ local border = {
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border })
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {border = border })
-- vim.cmd [[nnoremap <buffer><silent> <C-space> :lua vim.lsp.diagnostic.show_line_diagnostics({ border = border })<CR>]]
-- vim.cmd [[nnoremap <buffer><silent> ]g :lua vim.lsp.diagnostic.goto_next({ popup_opts = { border = border }})<CR>]]
-- vim.cmd [[nnoremap <buffer><silent> [g :lua vim.lsp.diagnostic.goto_prev({ popup_opts = { border = "round" }})<CR>]]