initial lsp config

This commit is contained in:
2023-04-03 14:50:08 +03:00
parent 308b6894b6
commit a74bc54f55
6 changed files with 137 additions and 68 deletions

View File

@@ -34,6 +34,10 @@
zsh # terminal requires it zsh # terminal requires it
git git
curl # needed to fetch titles from urls curl # needed to fetch titles from urls
zk # lsp for markdown notes
terraform-ls # terraform lsp
tflint # terraform linter
nodePackages.bash-language-server # bash lsp
]; ];
neovim-augmented = recursiveMerge [ neovim-augmented = recursiveMerge [
pkgs.neovim-unwrapped pkgs.neovim-unwrapped
@@ -61,7 +65,71 @@
packages.myPlugins = with pkgs.vimPlugins; { packages.myPlugins = with pkgs.vimPlugins; {
start = with pkgs.vimPlugins; [ start = with pkgs.vimPlugins; [
# Common dependencies of other plugins # Common dependencies of other plugins
popup-nvim # dependency of some other plugins plenary-nvim # dependency of some other plugins
todo-comments-nvim # highlight TODO comments
nvim-treesitter # syntax highlight
undotree # better vim file edit history
nvim-surround # .... updated lua-based alternative to tpope's surround
comment-nvim # code commenter
crates-nvim # inline intelligence for Cargo.toml
nvim-lspconfig # LSP for intilligent coding
null-ls-nvim # formatting and linting via lsp system
lspsaga-nvim
trouble-nvim # navigate all warnings and errors in quickfix-like window
fidget-nvim # show lsp status in bottom right but not status line
neodev-nvim # help for neovim lua api
lsp-format-nvim
SchemaStore-nvim # json schemas
# vim-fugitive # git control
# UI
onedarkpro-nvim # colorscheme
ir_black # colorscheme for basic terminals
telescope-nvim # da best popup fuzzy finder
telescope-fzy-native-nvim # with fzy gives better results
telescope-frecency-nvim # and frecency comes in handy too
nvim-colorizer-lua # color over CSS like #00ff00
nvim-web-devicons # makes things pretty; used by many plugins below
nvim-tree-lua # file navigator
gitsigns-nvim # git status in gutter
symbols-outline-nvim # navigate the current file better
lualine-nvim # nice status bar at bottom
vim-bbye # fix bdelete buffer stuff needed with bufferline
bufferline-nvim
indent-blankline-nvim # visual indent
toggleterm-nvim # better terminal management
nvim-treesitter.withAllGrammars # better code coloring
# playground # treesitter playground
nvim-treesitter-textobjects # jump around and select based on syntax (class, function, etc.)
nvim-treesitter-context # keep current block header (func defn or whatever) on first line
lf-vim
# Autocompletion
nvim-cmp # generic autocompleter
cmp-nvim-lsp # use lsp as source for completions
cmp-nvim-lua # makes vim config editing better with completions
cmp-buffer # any text in open buffers
cmp-path # complete paths
cmp-cmdline # completing in :commands
cmp-emoji # complete :emojis:
cmp-nvim-lsp-signature-help # help complete function call by showing args
cmp-npm # complete node packages in package.json
nvim-autopairs # balances parens as you type
nvim-ts-autotag # balance or rename html
vim-emoji # TODO: redundant now?
luasnip # snippets driver
cmp_luasnip # snippets completion
friendly-snippets # actual library of snippets used by luasnip
zk-nvim # lsp for a folder of notes for searching/linking/etc
true-zen-nvim # distraction free, width constrained writing mode
nui-nvim # UI Component Library for Neovim
gitsigns-nvim # git file changes
project-nvim
vim-tmux-navigator # navigate vim and tmux panes together
impatient-nvim # speeds startup times by caching lua bytecode
which-key-nvim # WhichKey is a lua plugin for Neovim 0.5 that displays a popup with possible key bindings of the command you started typing
diffview-nvim # git diff viewer
]; ];
opt = with pkgs.vimPlugins; [ opt = with pkgs.vimPlugins; [
# grammar check # grammar check

View File

@@ -1,19 +1,19 @@
-- Neovide needs this defined very early -- Neovide needs this defined very early
if vim.fn.has('mac') == 1 then -- if vim.fn.has('mac') == 1 then
vim.opt.guifont = "Hasklug Nerd Font:h18" -- vim.opt.guifont = "Hasklug Nerd Font:h18"
else -- else
vim.opt.guifont = "Hasklug Nerd Font:h9" -- vim.opt.guifont = "Hasklug Nerd Font:h9"
end -- end
-- require('impatient') require('impatient')
-- require('impatient').enable_profile() require('impatient').enable_profile()
-- require('pwnvim.filetypes').config() require('pwnvim.filetypes').config()
-- require('pwnvim.options').defaults() require('pwnvim.options').defaults()
-- require('pwnvim.options').gui() require('pwnvim.options').gui()
-- require('pwnvim.mappings') require('pwnvim.mappings')
-- require('pwnvim.abbreviations') require('pwnvim.abbreviations')
-- require('pwnvim.plugins').ui() require('pwnvim.plugins').ui()
-- require('pwnvim.plugins').diagnostics() require('pwnvim.plugins').diagnostics()
-- require('pwnvim.plugins').telescope() require('pwnvim.plugins').telescope()
-- require('pwnvim.plugins').completions() require('pwnvim.plugins').completions()
-- require('pwnvim.plugins').notes() require('pwnvim.plugins').notes()
-- require('pwnvim.plugins').misc() require('pwnvim.plugins').misc()

View File

@@ -30,15 +30,15 @@ M.config = function()
group = filetypes }) group = filetypes })
autocmd("FileType", autocmd("FileType",
{ pattern = { "c", "ruby", "php", "php3", "perl", "python", "mason", "vim", "sh", "zsh", "scala", "javascript", { pattern = { "c", "ruby", "php", "php3", "perl", "python", "mason", "vim", "sh", "zsh", "scala", "javascript",
"javascriptreact", "typescript", "typescriptreact", "html", "svelte", "css", "nix" }, "javascriptreact", "typescript", "typescriptreact", "html", "svelte", "css", "nix", "terraform" },
callback = function() require('pwnvim.options').programming() end, group = filetypes }) callback = function() require('pwnvim.options').programming() end, group = filetypes })
autocmd("FileType", autocmd("FileType",
{ pattern = { "lua", "xml" }, callback = function() require('pwnvim.filetypes').lua() end, group = filetypes }) { pattern = { "lua", "xml" }, callback = function() require('pwnvim.filetypes').lua() end, group = filetypes })
autocmd("FileType", autocmd("FileType",
{ pattern = { "md", "markdown", "vimwiki" }, callback = function() require('pwnvim.markdown').setup() end, { pattern = { "md", "markdown", "vimwiki" }, callback = function() require('pwnvim.markdown').setup() end,
group = filetypes }) group = filetypes })
autocmd("FileType", -- autocmd("FileType",
{ pattern = { "rust" }, callback = function() require('pwnvim.filetypes').rust() end, group = filetypes }) -- { pattern = { "rust" }, callback = function() require('pwnvim.filetypes').rust() end, group = filetypes })
autocmd("FileType", autocmd("FileType",
{ pattern = { "Outline" }, command = "setlocal nospell", group = filetypes }) { pattern = { "Outline" }, command = "setlocal nospell", group = filetypes })
@@ -49,29 +49,29 @@ M.config = function()
callback = function() require('pwnvim.filetypes').page() end }) callback = function() require('pwnvim.filetypes').page() end })
end end
M.rust = function() -- M.rust = function()
require('pwnvim.options').programming() -- require('pwnvim.options').programming()
require('pwnvim.options').fourspaceindent() -- require('pwnvim.options').fourspaceindent()
vim.bo.makeprg = "cargo" -- vim.bo.makeprg = "cargo"
vim.cmd("compiler cargo") -- vim.cmd("compiler cargo")
vim.g.rustfmt_autosave = 1 -- vim.g.rustfmt_autosave = 1
vim.g.rust_fold = 1 -- vim.g.rust_fold = 1
vim.api.nvim_exec([[ -- vim.api.nvim_exec([[
augroup rustquickfix -- augroup rustquickfix
autocmd! -- autocmd!
autocmd BufReadPost quickfix setlocal foldmethod=expr -- autocmd BufReadPost quickfix setlocal foldmethod=expr
autocmd BufReadPost quickfix setlocal foldexpr=getline(v:lnum)[0:1]=='\|\|' -- autocmd BufReadPost quickfix setlocal foldexpr=getline(v:lnum)[0:1]=='\|\|'
autocmd BufEnter quickfix setlocal foldexpr=getline(v:lnum)[0:1]=='\|\|' -- autocmd BufEnter quickfix setlocal foldexpr=getline(v:lnum)[0:1]=='\|\|'
autocmd BufReadPost quickfix setlocal foldlevel=0 -- autocmd BufReadPost quickfix setlocal foldlevel=0
augroup END -- augroup END
]], false) -- ]], false)
end -- end
M.c = function() -- M.c = function()
require('pwnvim.options').programming() -- require('pwnvim.options').programming()
require('pwnvim.options').fourspaceindent() -- require('pwnvim.options').fourspaceindent()
vim.bo.makeprg = "make" -- vim.bo.makeprg = "make"
end -- end
M.lua = function() M.lua = function()
require('pwnvim.options').programming() require('pwnvim.options').programming()

View File

@@ -115,22 +115,22 @@ M.setup = function()
-- auto_display = true -- WIP automatic markdown image display, may be prone to breaking -- auto_display = true -- WIP automatic markdown image display, may be prone to breaking
-- } -- }
-- end -- end
vim.cmd('packadd clipboard-image.nvim') -- vim.cmd('packadd clipboard-image.nvim')
require 'clipboard-image'.setup { -- require 'clipboard-image'.setup {
default = { -- default = {
img_name = function() -- img_name = function()
vim.fn.inputsave() -- vim.fn.inputsave()
local name = vim.fn.input({ prompt = "Name: " }) -- local name = vim.fn.input({ prompt = "Name: " })
-- TODO: swap spaces out for dashes -- -- TODO: swap spaces out for dashes
vim.fn.inputrestore() -- vim.fn.inputrestore()
return os.date('%Y-%m-%d') .. "-" .. name -- return os.date('%Y-%m-%d') .. "-" .. name
end, -- end,
img_dir = { "%:p:h", "%:t:r:s?$?_attachments?" }, -- img_dir = { "%:p:h", "%:t:r:s?$?_attachments?" },
img_dir_txt = "%:t:r:s?$?_attachments?", -- img_dir_txt = "%:t:r:s?$?_attachments?",
-- TODO: can I put the name as the title somehow? -- -- TODO: can I put the name as the title somehow?
affix = "![](%s)", -- affix = "![](%s)",
} -- }
} -- }
-- I have historically always used spaces for indents wherever possible including markdown -- I have historically always used spaces for indents wherever possible including markdown

View File

@@ -338,11 +338,11 @@ M.gui = function()
-- vim.opt.guifont = "Liga DejaVuSansMono Nerd Font:h16" -- vim.opt.guifont = "Liga DejaVuSansMono Nerd Font:h16"
-- vim.opt.guifont = "FiraCode Nerd Font:h16" -- no italics -- vim.opt.guifont = "FiraCode Nerd Font:h16" -- no italics
-- if vim.loop.os_uname().sysname == "Darwin" then -- if vim.loop.os_uname().sysname == "Darwin" then
if vim.fn.has('mac') == 1 then -- if vim.fn.has('mac') == 1 then
vim.opt.guifont = "Hasklug Nerd Font:h18" -- vim.opt.guifont = "Hasklug Nerd Font:h18"
else -- else
vim.opt.guifont = "Hasklug Nerd Font:h9" -- vim.opt.guifont = "Hasklug Nerd Font:h9"
end -- end
vim.g.neovide_transparency = 0.92 vim.g.neovide_transparency = 0.92
vim.g.neovide_cursor_animation_length = 0.01 vim.g.neovide_cursor_animation_length = 0.01
@@ -420,8 +420,8 @@ M.programming = function()
-- Load direnv when we're in a programming file as we may want -- Load direnv when we're in a programming file as we may want
-- the nix environment provided. Run explicitly since the autocmds -- the nix environment provided. Run explicitly since the autocmds
-- might not otherwise fire. -- might not otherwise fire.
vim.cmd('packadd direnv.vim') -- vim.cmd('packadd direnv.vim')
vim.cmd('DirenvExport') -- vim.cmd('DirenvExport')
end end
return M return M

View File

@@ -310,7 +310,6 @@ M.diagnostics = function()
} }
} }
} }
lspconfig.svelte.setup { on_attach = attached, capabilities = capabilities }
lspconfig.tailwindcss.setup { lspconfig.tailwindcss.setup {
on_attach = attached, on_attach = attached,
capabilities = capabilities, capabilities = capabilities,
@@ -351,6 +350,8 @@ M.diagnostics = function()
}, },
capabilities = capabilities capabilities = capabilities
} }
lspconfig.terraformls.setup { on_attach = attached, capabilities = capabilities } -- terraform lsp
lspconfig.tflint.setup { on_attach = attached, capabilities = capabilities } -- terraform lsp
require 'lspsaga'.init_lsp_saga({ require 'lspsaga'.init_lsp_saga({
use_saga_diagnostic_sign = not SimpleUI, use_saga_diagnostic_sign = not SimpleUI,