Compare commits
20 Commits
a660f0c788
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 38709a3b71 | |||
| 391b30bd7a | |||
| 0af71243a3 | |||
| d0ea7c50a0 | |||
| 233275c160 | |||
| ccd0319364 | |||
| f11dae4fce | |||
| 09e50948e4 | |||
| d1167c2fe9 | |||
| 04f1abe4d1 | |||
| 821f9bee27 | |||
| fbcc0b8d61 | |||
| 6a326d7321 | |||
| 36bb19fc4e | |||
| 8850a7cc27 | |||
| 480e35d011 | |||
| 95d3e129ad | |||
| 2e55a01664 | |||
| a233f6e7f2 | |||
| 8f4d2e287e |
@@ -75,25 +75,12 @@ require('lazy').setup({
|
||||
-- Detect tabstop and shiftwidth automatically
|
||||
'tpope/vim-sleuth',
|
||||
|
||||
-- NOTE: This is where your plugins related to LSP can be installed.
|
||||
-- The configuration is done below. Search for lspconfig to find it below.
|
||||
-- seems i need this regardless
|
||||
'neovim/nvim-lspconfig',
|
||||
{
|
||||
-- LSP Configuration & Plugins
|
||||
'neovim/nvim-lspconfig',
|
||||
dependencies = {
|
||||
-- Automatically install LSPs to stdpath for neovim
|
||||
{ 'williamboman/mason.nvim', config = true },
|
||||
'williamboman/mason-lspconfig.nvim',
|
||||
|
||||
-- Useful status updates for LSP
|
||||
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
|
||||
{ 'j-hui/fidget.nvim', tag = 'legacy', opts = {} },
|
||||
|
||||
-- Additional lua configuration, makes nvim stuff amazing!
|
||||
-- 'folke/neodev.nvim',
|
||||
},
|
||||
'williamboman/mason.nvim', config = true
|
||||
},
|
||||
|
||||
'williamboman/mason-lspconfig.nvim',
|
||||
{
|
||||
-- Autocompletion
|
||||
'hrsh7th/nvim-cmp',
|
||||
@@ -146,8 +133,7 @@ require('lazy').setup({
|
||||
|
||||
-- Fuzzy Finder (files, lsp, etc)
|
||||
{
|
||||
'nvim-telescope/telescope.nvim',
|
||||
branch = '0.1.x',
|
||||
'nvim-telescope/telescope.nvim', version = '*',
|
||||
dependencies = {
|
||||
'nvim-lua/plenary.nvim',
|
||||
-- Fuzzy Finder Algorithm which requires local dependencies to be built.
|
||||
@@ -167,31 +153,37 @@ require('lazy').setup({
|
||||
|
||||
{ -- Highlight, edit, and navigate code
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
branch="main",
|
||||
lazy = false,
|
||||
build = ':TSUpdate',
|
||||
main = 'nvim-treesitter.configs', -- Sets main module to use for opts
|
||||
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
|
||||
opts = {
|
||||
ensure_installed = { 'bash', 'php', 'rust', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' },
|
||||
-- Autoinstall languages that are not installed
|
||||
auto_install = true,
|
||||
highlight = {
|
||||
enable = true,
|
||||
-- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules.
|
||||
-- If you are experiencing weird indenting issues, add the language to
|
||||
-- the list of additional_vim_regex_highlighting and disabled languages for indent.
|
||||
additional_vim_regex_highlighting = { 'ruby' },
|
||||
},
|
||||
indent = { enable = true, disable = { 'ruby' } },
|
||||
},
|
||||
-- config = function()
|
||||
-- require('nvim-treesitter.configs').setup({
|
||||
-- ensure_installed = { 'bash', 'php', 'rust', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' },
|
||||
-- auto_install = true,
|
||||
-- highlight = {
|
||||
-- enable = true,
|
||||
-- additional_vim_regex_highlighting = { 'ruby' },
|
||||
-- },
|
||||
-- indent = { enable = true, disable = { 'ruby' } },
|
||||
-- })
|
||||
-- end,
|
||||
dependencies = {
|
||||
'nvim-treesitter/nvim-treesitter-textobjects',
|
||||
branch="main"
|
||||
},
|
||||
-- There are additional nvim-treesitter modules that you can use to interact
|
||||
-- with nvim-treesitter. You should go explore a few and see what interests you:
|
||||
--
|
||||
-- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
|
||||
-- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
|
||||
-- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
|
||||
init = function()
|
||||
local ensureInstalled = {
|
||||
'lua', 'python', 'typescript',
|
||||
-- ... your parsers
|
||||
}
|
||||
local alreadyInstalled = require('nvim-treesitter.config').get_installed()
|
||||
local parsersToInstall = vim.iter(ensureInstalled)
|
||||
:filter(function(parser)
|
||||
return not vim.tbl_contains(alreadyInstalled, parser)
|
||||
end)
|
||||
:totable()
|
||||
require('nvim-treesitter').install(parsersToInstall)
|
||||
end,
|
||||
},
|
||||
|
||||
-- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart
|
||||
@@ -282,53 +274,8 @@ vim.api.nvim_create_autocmd('TextYankPost', {
|
||||
-- Diagnostic keymaps
|
||||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' })
|
||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' })
|
||||
vim.keymap.set('n', '<leader>dd', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
|
||||
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })
|
||||
|
||||
-- [[ Configure LSP ]]
|
||||
-- This function gets run when an LSP connects to a particular buffer.
|
||||
local on_attach = function(_, bufnr)
|
||||
-- NOTE: Remember that lua is a real programming language, and as such it is possible
|
||||
-- to define small helper and utility functions so you don't have to repeat yourself
|
||||
-- many times.
|
||||
--
|
||||
-- In this case, we create a function that lets us more easily define mappings specific
|
||||
-- for LSP related items. It sets the mode, buffer and description for us each time.
|
||||
local nmap = function(keys, func, desc)
|
||||
if desc then
|
||||
desc = 'LSP: ' .. desc
|
||||
end
|
||||
|
||||
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
|
||||
end
|
||||
|
||||
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
|
||||
nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
|
||||
|
||||
nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition')
|
||||
nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
|
||||
nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation')
|
||||
nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition')
|
||||
nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
|
||||
nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
|
||||
|
||||
-- See `:help K` for why this keymap
|
||||
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
|
||||
nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')
|
||||
|
||||
-- Lesser used LSP functionality
|
||||
nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
|
||||
nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
|
||||
nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
|
||||
nmap('<leader>wl', function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, '[W]orkspace [L]ist Folders')
|
||||
|
||||
-- Create a command `:Format` local to the LSP buffer
|
||||
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
|
||||
vim.lsp.buf.format()
|
||||
end, { desc = 'Format current buffer with LSP' })
|
||||
end
|
||||
|
||||
-- Setup neovim lua configuration
|
||||
-- require('neodev').setup()
|
||||
|
||||
@@ -66,6 +66,7 @@ keymap.set('n', '<M-1>', '<cmd>ToggleTerm direction=horizontal<cr>', { silent =
|
||||
keymap.set('n', '<leader>f', '<Plug>(easymotion-prefix)', { silent = true })
|
||||
keymap.set('n', '<leader>fs', '<Plug>(easymotion-sn)', { silent = true })
|
||||
keymap.set('n', '<leader>w', '<Plug>(easymotion-overwin-f2)', { silent = true })
|
||||
keymap.set('n', 'gl', '<Plug>(easymotion-sl)', { silent = true })
|
||||
|
||||
vim.g.EasyMotion_smartcase = 1
|
||||
|
||||
|
||||
+35
-28
@@ -55,7 +55,10 @@ local on_attach = function(_, bufnr)
|
||||
keymap.set("n", "g0", "<cmd>lua vim.lsp.buf.document_symbol()<CR>", opts)
|
||||
keymap.set("n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
||||
keymap.set("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
|
||||
keymap.set("n", "<leader>l", smart_format, opts)
|
||||
-- keymap.set("n", "<leader>l", smart_format, opts)
|
||||
keymap.set("n", "<leader>l", function()
|
||||
vim.lsp.buf.format()
|
||||
end, { desc = "Format code function" })
|
||||
keymap.set("n", "<leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
|
||||
keymap.set(
|
||||
"n",
|
||||
@@ -73,13 +76,15 @@ local on_attach = function(_, bufnr)
|
||||
keymap.set("n", "<leader>ca", "<cmd>Lspsaga code_action<CR>", opts)
|
||||
keymap.set("n", "ge", "<cmd>Lspsaga show_line_diagnostics<CR>", opts)
|
||||
keymap.set("n", "<a-cr>", "<cmd>Lspsaga code_action<CR>", opts)
|
||||
keymap.set("n", "<leader>d", "<cmd>Telescope diagnostics<CR>", opts)
|
||||
-- keymap.set("n", "<leader>d", "<cmd>Telescope diagnostics<CR>", opts)
|
||||
keymap.set("n", "<leader>da", "<cmd>Lspsaga show_workspace_diagnostics ++float<CR>", opts)
|
||||
keymap.set("n", "<leader>db", "<cmd>Lspsaga show_buf_diagnostics ++float<CR>", opts)
|
||||
keymap.set("n", "<leader>dn", "<cmd>Lspsaga diagnostic_jump_next<CR>")
|
||||
keymap.set("n", "<leader>dp", "<cmd>Lspsaga diagnostic_jump_prev<CR>")
|
||||
|
||||
keymap.set("n", "gj", "<cmd>lua require'nvim-treesitter.textobjects.move'.goto_next_start('@function.outer')<CR>",
|
||||
keymap.set("n", "gj", "<cmd>lua require'nvim-treesitter-textobjects.move'.goto_next_start('@function.outer')<CR>",
|
||||
opts)
|
||||
keymap.set("n", "gk", "<cmd>lua require'nvim-treesitter.textobjects.move'.goto_previous_start('@function.outer')<CR>",
|
||||
keymap.set("n", "gk", "<cmd>lua require'nvim-treesitter-textobjects.move'.goto_previous_start('@function.outer')<CR>",
|
||||
opts)
|
||||
end
|
||||
|
||||
@@ -105,25 +110,19 @@ setup_server("pyright", { filetypes = { "py" } })
|
||||
setup_server("html", { filetypes = { "html" } })
|
||||
setup_server("cssls",
|
||||
{ filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" } })
|
||||
setup_server("tailwindcss", {
|
||||
filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" },
|
||||
})
|
||||
setup_server("emmet_ls", {
|
||||
filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" },
|
||||
})
|
||||
setup_server("eslint", {
|
||||
filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" },
|
||||
})
|
||||
setup_server("rust_analyzer", {
|
||||
settings = {
|
||||
["rust-analyzer"] = { checkOnSave = true },
|
||||
["rust-analyzer"] = { checkOnSave = true, check = { command = "clippy" } },
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
-- PHP LSPs
|
||||
local util = vim.lsp.util
|
||||
root_dir = function(fname)
|
||||
local root_dir = function(fname)
|
||||
return util.root_pattern("composer.json", ".git")(fname)
|
||||
or util.path.dirname(fname)
|
||||
end
|
||||
@@ -132,21 +131,23 @@ local fallback_root_dir = function(fname)
|
||||
return util.root_pattern("composer.json", ".git")(fname) or util.path.dirname(fname)
|
||||
end
|
||||
|
||||
setup_server("phpactor", {
|
||||
filetypes = { "php" },
|
||||
-- root_dir = fallback_root_dir,
|
||||
init_options = {
|
||||
["language_server_phpstan.enabled"] = true,
|
||||
["language_server_psalm.enabled"] = false,
|
||||
},
|
||||
})
|
||||
-- start it manually :LspStart phpactor
|
||||
-- setup_server("phpactor", {
|
||||
-- filetypes = { "php" },
|
||||
-- -- root_dir = fallback_root_dir,
|
||||
-- init_options = {
|
||||
-- ["language_server_phpstan.enabled"] = true,
|
||||
-- ["language_server_psalm.enabled"] = false,
|
||||
-- },
|
||||
-- })
|
||||
|
||||
vim.lsp.config("lua_ls", {
|
||||
setup_server("lua_ls", {
|
||||
filetypes = { "lua" },
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
globals = { "vim" } }
|
||||
globals = { "vim" } },
|
||||
format = { enable = true },
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -155,7 +156,13 @@ setup_server("intelephense", {
|
||||
filetypes = { "php" },
|
||||
-- root_dir = fallback_root_dir,
|
||||
init_options = {
|
||||
licenceKey = vim.fn.readfile(vim.fn.expand("$HOME/.config/intelephense/license.txt"))[1],
|
||||
licenceKey = (function()
|
||||
local license_path = vim.fn.expand("$HOME/.config/intelephense/license.txt")
|
||||
if vim.fn.filereadable(license_path) == 1 then
|
||||
return vim.fn.readfile(license_path)[1]
|
||||
end
|
||||
return nil
|
||||
end)(),
|
||||
},
|
||||
settings = {
|
||||
intelephense = {
|
||||
@@ -179,10 +186,10 @@ setup_server("intelephense", {
|
||||
-- phpcs / phpstan configs
|
||||
vim.g.nvim_phpcs_config_phpcs_path = 'phpcs'
|
||||
vim.g.nvim_phpcs_config_phpcbf_path = 'phpcbf'
|
||||
vim.g.ale_php_phpstan_executable = '/home/mace/.config/composer/vendor/bin/phpstan'
|
||||
vim.g.ale_php_phpstan_executable = '~/.config/composer/vendor/bin/phpstan'
|
||||
|
||||
local phpcs_config = "/home/mace/repos/configs/phpcs.xml"
|
||||
local phpcs_config_new = "/home/mace/repos/dotfiles/phpcs.xml"
|
||||
local phpcs_config = "~/repos/configs/phpcs.xml"
|
||||
local phpcs_config_new = "~/repos/dotfiles/phpcs.xml"
|
||||
if vim.loop.fs_stat(phpcs_config_new) then
|
||||
vim.g.nvim_phpcs_config_phpcs_standard = phpcs_config_new
|
||||
elseif vim.loop.fs_stat(phpcs_config) then
|
||||
@@ -193,7 +200,7 @@ end
|
||||
-- call this early in your init (so FileType autocommands are installed before opening files)
|
||||
local enabled_servers = {
|
||||
"bashls", "lemminx", "yamlls", "jsonls", "pyright", "html", "cssls",
|
||||
"tailwindcss", "emmet_ls", "eslint", "rust_analyzer", "lua_ls",
|
||||
"phpactor", "intelephense"
|
||||
"eslint", "rust_analyzer", "lua_ls",
|
||||
"intelephense"
|
||||
}
|
||||
vim.lsp.enable(enabled_servers)
|
||||
|
||||
+32
-7
@@ -19,6 +19,11 @@ end
|
||||
-- load vs-code like snippets from plugins (e.g. friendly-snippets)
|
||||
require("luasnip/loaders/from_vscode").lazy_load()
|
||||
|
||||
local function has_words_before()
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||
end
|
||||
|
||||
vim.opt.completeopt = "menu,menuone,noselect"
|
||||
|
||||
cmp.setup({
|
||||
@@ -34,20 +39,40 @@ cmp.setup({
|
||||
},
|
||||
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<C-k>"] = cmp.mapping.select_prev_item(), -- previous suggestion
|
||||
["<C-j>"] = cmp.mapping.select_next_item(), -- next suggestion
|
||||
["<C-k>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
|
||||
["<C-j>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
|
||||
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-Space>"] = cmp.mapping.complete(), -- show completion suggestions
|
||||
["<C-e>"] = cmp.mapping.abort(), -- close completion window
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<C-e>"] = cmp.mapping.abort(),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||
}),
|
||||
-- sources for autocompletion
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp" }, -- lsp
|
||||
{ name = "luasnip" }, -- snippets
|
||||
{ name = "nvim_lsp" }, -- lsp
|
||||
{ name = "luasnip" }, -- snippets
|
||||
{ name = "buffer", keyword_length = 5 }, -- text within current buffer
|
||||
{ name = "path" }, -- file system paths
|
||||
{ name = "path" }, -- file system paths
|
||||
}),
|
||||
-- configure lspkind for vs-code like icons
|
||||
formatting = {
|
||||
|
||||
@@ -74,13 +74,15 @@ return {
|
||||
"easymotion/vim-easymotion",
|
||||
|
||||
-- Markdown
|
||||
{
|
||||
"iamcco/markdown-preview.nvim",
|
||||
ft = "markdown",
|
||||
build = function()
|
||||
vim.fn["mkdp#util#install"]()
|
||||
end,
|
||||
},
|
||||
-- {
|
||||
-- "iamcco/markdown-preview.nvim",
|
||||
-- cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" },
|
||||
-- build = "cd app && yarn install",
|
||||
-- init = function()
|
||||
-- vim.g.mkdp_filetypes = { "markdown" }
|
||||
-- end,
|
||||
-- ft = { "markdown" },
|
||||
-- },
|
||||
|
||||
{
|
||||
'akinsho/bufferline.nvim',
|
||||
|
||||
@@ -23,6 +23,9 @@ telescope.setup({
|
||||
['<C-d>'] = false,
|
||||
},
|
||||
},
|
||||
preview = {
|
||||
treesitter = false,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ nnoremap ,b :buffers<CR>
|
||||
nnoremap <leader>y "+yy
|
||||
vnoremap <leader>y "+y
|
||||
|
||||
:nnoremap <Leader>s :%s/\<<C-r><C-w>\>/
|
||||
":nnoremap <Leader>s :%s/\<<C-r><C-w>\>/
|
||||
" xnoremap ("<leader>p", "\"_dP")
|
||||
" autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
|
||||
|
||||
|
||||
Reference in New Issue
Block a user