From 4841ea7646de82d72bb7b1a983f08b776682d732 Mon Sep 17 00:00:00 2001 From: smoon Date: Tue, 18 Jun 2024 11:47:43 -0700 Subject: [PATCH 1/5] config updates --- init.lua | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 83 insertions(+), 6 deletions(-) diff --git a/init.lua b/init.lua index 16d3c26b..557a7c74 100644 --- a/init.lua +++ b/init.lua @@ -99,7 +99,7 @@ vim.g.maplocalleader = ' ' vim.opt.number = true -- You can also add relative line numbers, for help with jumping. -- Experiment for yourself to see if you like it! --- vim.opt.relativenumber = true +vim.opt.relativenumber = true -- Enable mouse mode, can be useful for resizing splits for example! vim.opt.mouse = 'a' @@ -155,6 +155,9 @@ vim.opt.scrolloff = 10 vim.opt.hlsearch = true vim.keymap.set('n', '', 'nohlsearch') +vim.opt.tabstop = 4 +vim.opt.shiftwidth = 4 + -- Diagnostic keymaps vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' }) vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' }) @@ -221,6 +224,7 @@ vim.opt.rtp:prepend(lazypath) require('lazy').setup { -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically + 'tpope/vim-fugitive', -- Git commands in nvim -- NOTE: Plugins can also be added by using a table, -- with the first argument being the link and the following @@ -290,6 +294,9 @@ require('lazy').setup { -- you do for a plugin at the top level, you can do for a dependency. -- -- Use the `dependencies` key to specify the dependencies of a particular plugin + { + 'github/copilot.vim', + }, { -- Fuzzy Finder (files, lsp, etc) 'nvim-telescope/telescope.nvim', @@ -543,6 +550,24 @@ require('lazy').setup { -- But for many setups, the LSP (`tsserver`) will work just fine -- tsserver = {}, -- + intelephense = {}, + terraformls = {}, + templ = { + filetypes = { 'templ' }, + }, + tsserver = {}, + gopls = { + settings = { + gopls = { + analyses = { + unusedparams = true, + }, + staticcheck = true, + gofumpt = true, + }, + }, + }, + -- phan = {}, lua_ls = { -- cmd = {...}, @@ -607,10 +632,13 @@ require('lazy').setup { 'stevearc/conform.nvim', opts = { notify_on_error = false, - format_on_save = { - timeout_ms = 500, - lsp_fallback = true, - }, + format_on_save = function(bufnr) + -- Disable with a global or buffer-local variable + if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then + return + end + return { timeout_ms = 500, lsp_fallback = true } + end, formatters_by_ft = { lua = { 'stylua' }, -- Conform can also run multiple formatters sequentially @@ -781,7 +809,7 @@ require('lazy').setup { ---@diagnostic disable-next-line: missing-fields require('nvim-treesitter.configs').setup { - ensure_installed = { 'bash', 'c', 'html', 'lua', 'markdown', 'vim', 'vimdoc' }, + ensure_installed = { 'bash', 'c', 'go', 'html', 'javascript', 'lua', 'markdown', 'php', 'terraform', 'vim', 'vimdoc' }, -- Autoinstall languages that are not installed auto_install = true, highlight = { enable = true }, @@ -819,3 +847,52 @@ require('lazy').setup { -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et + +vim.filetype.add { + extension = { + templ = 'templ', + }, +} + +-- Toggle Auto formatting +vim.api.nvim_create_user_command('FormatDisable', function(args) + if args.bang then + -- FormatDisable! will disable formatting just for this buffer + vim.b.disable_autoformat = true + else + vim.g.disable_autoformat = true + end +end, { + desc = 'Disable autoformat-on-save', + bang = true, +}) +vim.api.nvim_create_user_command('FormatEnable', function() + vim.b.disable_autoformat = false + vim.g.disable_autoformat = false +end, { + desc = 'Re-enable autoformat-on-save', +}) + +-- Automatically organize imports and format Go code on save +vim.api.nvim_create_autocmd('BufWritePre', { + pattern = '*.go', + callback = function() + local params = vim.lsp.util.make_range_params() + params.context = { only = { 'source.organizeImports' } } + -- buf_request_sync defaults to a 1000ms timeout. Depending on your + -- machine and codebase, you may want longer. Add an additional + -- argument after params if you find that you have to write the file + -- twice for changes to be saved. + -- E.g., vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, 3000) + local result = vim.lsp.buf_request_sync(0, 'textDocument/codeAction', params) + for cid, res in pairs(result or {}) do + for _, r in pairs(res.result or {}) do + if r.edit then + local enc = (vim.lsp.get_client_by_id(cid) or {}).offset_encoding or 'utf-16' + vim.lsp.util.apply_workspace_edit(r.edit, enc) + end + end + end + vim.lsp.buf.format { async = false } + end, +}) From 0c4d126ec1bfcd5cd0b017cc4834523d0e574dc5 Mon Sep 17 00:00:00 2001 From: smoon Date: Fri, 23 Aug 2024 12:43:19 -0700 Subject: [PATCH 2/5] Add jedi lang server --- init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/init.lua b/init.lua index 557a7c74..c6322509 100644 --- a/init.lua +++ b/init.lua @@ -550,6 +550,7 @@ require('lazy').setup { -- But for many setups, the LSP (`tsserver`) will work just fine -- tsserver = {}, -- + jedi_language_server = {}, intelephense = {}, terraformls = {}, templ = { From 7336c66f1653fd506d8595dd737df1a537430915 Mon Sep 17 00:00:00 2001 From: smoon Date: Tue, 18 Jun 2024 11:47:43 -0700 Subject: [PATCH 3/5] config updates # Conflicts: # init.lua --- init.lua | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 78 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 41b5a97b..57b1ece3 100644 --- a/init.lua +++ b/init.lua @@ -102,7 +102,7 @@ vim.g.have_nerd_font = false vim.opt.number = true -- You can also add relative line numbers, to help with jumping. -- Experiment for yourself to see if you like it! --- vim.opt.relativenumber = true +vim.opt.relativenumber = true -- Enable mouse mode, can be useful for resizing splits for example! vim.opt.mouse = 'a' @@ -164,7 +164,13 @@ vim.opt.scrolloff = 10 -- See `:help hlsearch` vim.keymap.set('n', '', 'nohlsearch') +vim.opt.tabstop = 4 +vim.opt.shiftwidth = 4 + -- Diagnostic keymaps +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' }) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' }) +vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' }) vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) -- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier @@ -230,6 +236,7 @@ vim.opt.rtp:prepend(lazypath) require('lazy').setup({ -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically + 'tpope/vim-fugitive', -- Git commands in nvim -- NOTE: Plugins can also be added by using a table, -- with the first argument being the link and the following @@ -333,6 +340,9 @@ require('lazy').setup({ -- you do for a plugin at the top level, you can do for a dependency. -- -- Use the `dependencies` key to specify the dependencies of a particular plugin + { + 'github/copilot.vim', + }, { -- Fuzzy Finder (files, lsp, etc) 'nvim-telescope/telescope.nvim', @@ -618,6 +628,24 @@ require('lazy').setup({ -- But for many setups, the LSP (`tsserver`) will work just fine -- tsserver = {}, -- + intelephense = {}, + terraformls = {}, + templ = { + filetypes = { 'templ' }, + }, + tsserver = {}, + gopls = { + settings = { + gopls = { + analyses = { + unusedparams = true, + }, + staticcheck = true, + gofumpt = true, + }, + }, + }, + -- phan = {}, lua_ls = { -- cmd = {...}, @@ -949,3 +977,52 @@ require('lazy').setup({ -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et + +vim.filetype.add { + extension = { + templ = 'templ', + }, +} + +-- Toggle Auto formatting +vim.api.nvim_create_user_command('FormatDisable', function(args) + if args.bang then + -- FormatDisable! will disable formatting just for this buffer + vim.b.disable_autoformat = true + else + vim.g.disable_autoformat = true + end +end, { + desc = 'Disable autoformat-on-save', + bang = true, +}) +vim.api.nvim_create_user_command('FormatEnable', function() + vim.b.disable_autoformat = false + vim.g.disable_autoformat = false +end, { + desc = 'Re-enable autoformat-on-save', +}) + +-- Automatically organize imports and format Go code on save +vim.api.nvim_create_autocmd('BufWritePre', { + pattern = '*.go', + callback = function() + local params = vim.lsp.util.make_range_params() + params.context = { only = { 'source.organizeImports' } } + -- buf_request_sync defaults to a 1000ms timeout. Depending on your + -- machine and codebase, you may want longer. Add an additional + -- argument after params if you find that you have to write the file + -- twice for changes to be saved. + -- E.g., vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, 3000) + local result = vim.lsp.buf_request_sync(0, 'textDocument/codeAction', params) + for cid, res in pairs(result or {}) do + for _, r in pairs(res.result or {}) do + if r.edit then + local enc = (vim.lsp.get_client_by_id(cid) or {}).offset_encoding or 'utf-16' + vim.lsp.util.apply_workspace_edit(r.edit, enc) + end + end + end + vim.lsp.buf.format { async = false } + end, +}) From f833a21ae56c1b867520ad17a4cd66417d385945 Mon Sep 17 00:00:00 2001 From: smoon Date: Fri, 23 Aug 2024 12:43:19 -0700 Subject: [PATCH 4/5] Add jedi lang server --- init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/init.lua b/init.lua index 57b1ece3..d2184dd7 100644 --- a/init.lua +++ b/init.lua @@ -628,6 +628,7 @@ require('lazy').setup({ -- But for many setups, the LSP (`tsserver`) will work just fine -- tsserver = {}, -- + jedi_language_server = {}, intelephense = {}, terraformls = {}, templ = { From 6029ee537a885bcd7f376d24c07b7495dbe53c18 Mon Sep 17 00:00:00 2001 From: smoon Date: Sat, 24 May 2025 18:32:35 -0700 Subject: [PATCH 5/5] some ts_server updates --- init.lua | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index d2184dd7..c1ed8d01 100644 --- a/init.lua +++ b/init.lua @@ -91,7 +91,7 @@ vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -- Set to true if you have a Nerd Font installed and selected in the terminal -vim.g.have_nerd_font = false +vim.g.have_nerd_font = true -- [[ Setting options ]] -- See `:help vim.opt` @@ -628,13 +628,34 @@ require('lazy').setup({ -- But for many setups, the LSP (`tsserver`) will work just fine -- tsserver = {}, -- + volar = {}, jedi_language_server = {}, intelephense = {}, terraformls = {}, templ = { filetypes = { 'templ' }, }, - tsserver = {}, + ts_ls = { + settings = { + implicitProjectConfiguration = { + checkJs = true, + }, + }, + init_options = { + plugins = { + { + name = '@vue/typescript-plugin', + location = '/home/ocxm/.asdf/installs/nodejs/23.2.0/lib/node_modules/@vue/typescript-plugin', + languages = { 'javascript', 'typescript', 'vue' }, + }, + }, + }, + filetypes = { + 'javascript', + 'typescript', + 'vue', + }, + }, gopls = { settings = { gopls = { @@ -912,7 +933,23 @@ require('lazy').setup({ main = 'nvim-treesitter.configs', -- Sets main module to use for opts -- [[ Configure Treesitter ]] See `:help nvim-treesitter` opts = { - ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, + ensure_installed = { + 'bash', + 'c', + 'diff', + 'go', + 'html', + 'javascript', + 'lua', + 'luadoc', + 'markdown', + 'markdown_inline', + 'php', + 'query', + 'terraform', + 'vim', + 'vimdoc', + }, -- Autoinstall languages that are not installed auto_install = true, highlight = {